fixed race condition

This commit is contained in:
orignal 2015-01-11 21:00:38 -05:00
parent 6683a9cf76
commit a85cc6aa77
4 changed files with 12 additions and 4 deletions

View File

@ -627,6 +627,11 @@ namespace transport
}
void NTCPSession::SendI2NPMessage (I2NPMessage * msg)
{
m_Server.GetService ().post (std::bind (&NTCPSession::PostI2NPMessage, shared_from_this (), msg));
}
void NTCPSession::PostI2NPMessage (I2NPMessage * msg)
{
if (msg)
{
@ -634,9 +639,9 @@ namespace transport
Send (msg);
else
m_DelayedMessages.push_back (msg);
}
}
}
void NTCPSession::ScheduleTermination ()
{
m_TerminationTimer.cancel ();

View File

@ -67,6 +67,7 @@ namespace transport
protected:
void PostI2NPMessage (I2NPMessage * msg);
void Connected ();
void SendTimeSyncMessage ();
void SetIsEstablished (bool isEstablished) { m_IsEstablished = isEstablished; }

3
SSU.h
View File

@ -38,7 +38,8 @@ namespace transport
void DeleteSession (std::shared_ptr<SSUSession> session);
void DeleteAllSessions ();
boost::asio::io_service& GetService () { return m_Socket.get_io_service(); };
boost::asio::io_service& GetService () { return m_Service; };
boost::asio::io_service& GetServiceV6 () { return m_ServiceV6; };
const boost::asio::ip::udp::endpoint& GetEndpoint () const { return m_Endpoint; };
void Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to);
void AddRelay (uint32_t tag, const boost::asio::ip::udp::endpoint& relay);

View File

@ -828,7 +828,8 @@ namespace transport
void SSUSession::SendI2NPMessage (I2NPMessage * msg)
{
m_Server.GetService ().post (std::bind (&SSUSession::PostI2NPMessage, shared_from_this (), msg));
boost::asio::io_service& service = IsV6 () ? m_Server.GetServiceV6 () : m_Server.GetService ();
service.post (std::bind (&SSUSession::PostI2NPMessage, shared_from_this (), msg));
}
void SSUSession::PostI2NPMessage (I2NPMessage * msg)