mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
fixed race condition
This commit is contained in:
parent
124007dc31
commit
cade0e6afa
2 changed files with 4 additions and 0 deletions
|
@ -751,6 +751,7 @@ namespace data
|
|||
if (it == m_RequestedDestinations.end ()) // not exist yet
|
||||
{
|
||||
RequestedDestination * d = new RequestedDestination (dest, isLeaseSet, isExploratory, pool);
|
||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||
m_RequestedDestinations[dest] = d;
|
||||
return d;
|
||||
}
|
||||
|
@ -764,6 +765,7 @@ namespace data
|
|||
if (it != m_RequestedDestinations.end ())
|
||||
{
|
||||
delete it->second;
|
||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||
m_RequestedDestinations.erase (it);
|
||||
return true;
|
||||
}
|
||||
|
@ -774,6 +776,7 @@ namespace data
|
|||
{
|
||||
if (dest)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||
m_RequestedDestinations.erase (dest->GetDestination ());
|
||||
delete dest;
|
||||
}
|
||||
|
|
1
NetDb.h
1
NetDb.h
|
@ -110,6 +110,7 @@ namespace data
|
|||
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
||||
std::map<IdentHash, RouterInfo *> m_RouterInfos;
|
||||
std::vector<RouterInfo *> m_Floodfills;
|
||||
std::mutex m_RequestedDestinationsMutex;
|
||||
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
||||
std::set<IdentHash> m_Subscriptions;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue