mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
fixed race condition
This commit is contained in:
parent
c4c614bc3d
commit
98361dc8f9
@ -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…
x
Reference in New Issue
Block a user