mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
fixed race condition
This commit is contained in:
parent
124007dc31
commit
cade0e6afa
@ -751,6 +751,7 @@ namespace data
|
|||||||
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,6 +765,7 @@ namespace data
|
|||||||
if (it != m_RequestedDestinations.end ())
|
if (it != m_RequestedDestinations.end ())
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
m_RequestedDestinations.erase (it);
|
m_RequestedDestinations.erase (it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -774,6 +776,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
if (dest)
|
if (dest)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
m_RequestedDestinations.erase (dest->GetDestination ());
|
m_RequestedDestinations.erase (dest->GetDestination ());
|
||||||
delete dest;
|
delete dest;
|
||||||
}
|
}
|
||||||
|
1
NetDb.h
1
NetDb.h
@ -110,6 +110,7 @@ namespace data
|
|||||||
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
||||||
std::map<IdentHash, RouterInfo *> m_RouterInfos;
|
std::map<IdentHash, RouterInfo *> m_RouterInfos;
|
||||||
std::vector<RouterInfo *> m_Floodfills;
|
std::vector<RouterInfo *> m_Floodfills;
|
||||||
|
std::mutex m_RequestedDestinationsMutex;
|
||||||
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
||||||
std::set<IdentHash> m_Subscriptions;
|
std::set<IdentHash> m_Subscriptions;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user