mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
fixed race condition
This commit is contained in:
parent
78fc3876e6
commit
0f3a68cd8e
4 changed files with 11 additions and 0 deletions
3
SAM.cpp
3
SAM.cpp
|
@ -582,6 +582,7 @@ namespace stream
|
|||
{
|
||||
SAMSession session;
|
||||
session.localDestination = localDestination;
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
auto ret = m_Sessions.insert (std::pair<std::string, SAMSession>(id, session));
|
||||
if (!ret.second)
|
||||
LogPrint ("Session ", id, " already exists");
|
||||
|
@ -592,6 +593,7 @@ namespace stream
|
|||
|
||||
void SAMBridge::CloseSession (const std::string& id)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
auto it = m_Sessions.find (id);
|
||||
if (it != m_Sessions.end ())
|
||||
{
|
||||
|
@ -605,6 +607,7 @@ namespace stream
|
|||
|
||||
SAMSession * SAMBridge::FindSession (const std::string& id)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
auto it = m_Sessions.find (id);
|
||||
if (it != m_Sessions.end ())
|
||||
return &it->second;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue