mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
fixed race condition
This commit is contained in:
parent
481b54a817
commit
711b4ab9ae
@ -308,12 +308,16 @@ namespace garlic
|
|||||||
if (!session)
|
if (!session)
|
||||||
{
|
{
|
||||||
session = new GarlicRoutingSession (&destination, 32);
|
session = new GarlicRoutingSession (&destination, 32);
|
||||||
|
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||||
m_Sessions[destination.GetIdentHash ()] = session;
|
m_Sessions[destination.GetIdentHash ()] = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
I2NPMessage * ret = session->WrapSingleMessage (msg, leaseSet);
|
I2NPMessage * ret = session->WrapSingleMessage (msg, leaseSet);
|
||||||
if (!session->GetNextTag ()) // tags have beed recreated
|
if (!session->GetNextTag ()) // tags have beed recreated
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||||
m_CreatedSessions[session->GetFirstMsgID ()] = session;
|
m_CreatedSessions[session->GetFirstMsgID ()] = session;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
Garlic.h
2
Garlic.h
@ -6,6 +6,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
#include <cryptopp/osrng.h>
|
#include <cryptopp/osrng.h>
|
||||||
#include "aes.h"
|
#include "aes.h"
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
@ -121,6 +122,7 @@ namespace garlic
|
|||||||
std::thread * m_Thread;
|
std::thread * m_Thread;
|
||||||
i2p::util::Queue<I2NPMessage> m_Queue;
|
i2p::util::Queue<I2NPMessage> m_Queue;
|
||||||
// outgoing sessions
|
// outgoing sessions
|
||||||
|
std::mutex m_SessionsMutex;
|
||||||
std::map<i2p::data::IdentHash, GarlicRoutingSession *> m_Sessions;
|
std::map<i2p::data::IdentHash, GarlicRoutingSession *> m_Sessions;
|
||||||
std::map<uint32_t, GarlicRoutingSession *> m_CreatedSessions; // msgID -> session
|
std::map<uint32_t, GarlicRoutingSession *> m_CreatedSessions; // msgID -> session
|
||||||
// incoming session
|
// incoming session
|
||||||
|
Loading…
Reference in New Issue
Block a user