mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
fixed race condition
This commit is contained in:
parent
c4c614bc3d
commit
98361dc8f9
1 changed files with 2 additions and 2 deletions
|
@ -747,11 +747,11 @@ namespace data
|
||||||
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest,
|
||||||
bool isLeaseSet, bool isExploratory, i2p::tunnel::TunnelPool * pool)
|
bool isLeaseSet, bool isExploratory, i2p::tunnel::TunnelPool * pool)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
auto it = m_RequestedDestinations.find (dest);
|
auto it = m_RequestedDestinations.find (dest);
|
||||||
if (it == m_RequestedDestinations.end ()) // not exist yet
|
if (it == m_RequestedDestinations.end ()) // not exist yet
|
||||||
{
|
{
|
||||||
RequestedDestination * d = new RequestedDestination (dest, isLeaseSet, isExploratory, pool);
|
RequestedDestination * d = new RequestedDestination (dest, isLeaseSet, isExploratory, pool);
|
||||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
|
||||||
m_RequestedDestinations[dest] = d;
|
m_RequestedDestinations[dest] = d;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
@ -764,8 +764,8 @@ namespace data
|
||||||
auto it = m_RequestedDestinations.find (dest);
|
auto it = m_RequestedDestinations.find (dest);
|
||||||
if (it != m_RequestedDestinations.end ())
|
if (it != m_RequestedDestinations.end ())
|
||||||
{
|
{
|
||||||
delete it->second;
|
|
||||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
|
delete it->second;
|
||||||
m_RequestedDestinations.erase (it);
|
m_RequestedDestinations.erase (it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue