diff --git a/NetDb.cpp b/NetDb.cpp index f3719290..2202b718 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -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 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 l(m_RequestedDestinationsMutex); m_RequestedDestinations.erase (it); return true; } @@ -774,6 +776,7 @@ namespace data { if (dest) { + std::unique_lock l(m_RequestedDestinationsMutex); m_RequestedDestinations.erase (dest->GetDestination ()); delete dest; } diff --git a/NetDb.h b/NetDb.h index 16513bd9..6ee065d4 100644 --- a/NetDb.h +++ b/NetDb.h @@ -110,6 +110,7 @@ namespace data std::map m_LeaseSets; std::map m_RouterInfos; std::vector m_Floodfills; + std::mutex m_RequestedDestinationsMutex; std::map m_RequestedDestinations; std::set m_Subscriptions;