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
43f8ec46cc
commit
19325d552a
24
Streaming.h
24
Streaming.h
@ -228,20 +228,18 @@ namespace stream
|
|||||||
template<typename Buffer, typename ReceiveHandler>
|
template<typename Buffer, typename ReceiveHandler>
|
||||||
void Stream::AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout)
|
void Stream::AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout)
|
||||||
{
|
{
|
||||||
if (!m_ReceiveQueue.empty ())
|
auto s = shared_from_this();
|
||||||
|
m_Service.post ([=](void)
|
||||||
{
|
{
|
||||||
auto s = shared_from_this();
|
if (!m_ReceiveQueue.empty () || m_Status == eStreamStatusReset)
|
||||||
m_Service.post ([=](void) { s->HandleReceiveTimer (
|
s->HandleReceiveTimer (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), buffer, handler);
|
||||||
boost::asio::error::make_error_code (boost::asio::error::operation_aborted),
|
else
|
||||||
buffer, handler); });
|
{
|
||||||
}
|
m_ReceiveTimer.expires_from_now (boost::posix_time::seconds(timeout));
|
||||||
else
|
m_ReceiveTimer.async_wait ([=](const boost::system::error_code& ecode)
|
||||||
{
|
{ s->HandleReceiveTimer (ecode, buffer, handler); });
|
||||||
m_ReceiveTimer.expires_from_now (boost::posix_time::seconds(timeout));
|
}
|
||||||
auto s = shared_from_this();
|
});
|
||||||
m_ReceiveTimer.async_wait ([=](const boost::system::error_code& ecode)
|
|
||||||
{ s->HandleReceiveTimer (ecode, buffer, handler); });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Buffer, typename ReceiveHandler>
|
template<typename Buffer, typename ReceiveHandler>
|
||||||
|
Loading…
Reference in New Issue
Block a user