mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
don't lock mutex in AsyncSend
This commit is contained in:
parent
9632e7ba03
commit
8d6eb5b6b2
@ -532,14 +532,18 @@ namespace stream
|
||||
|
||||
void Stream::AsyncSend (const uint8_t * buf, size_t len, SendHandler handler)
|
||||
{
|
||||
std::shared_ptr<i2p::stream::SendBuffer> buffer;
|
||||
if (len > 0 && buf)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_SendBufferMutex);
|
||||
m_SendBuffer.Add (buf, len, handler);
|
||||
}
|
||||
buffer = std::make_shared<i2p::stream::SendBuffer>(buf, len, handler);
|
||||
else if (handler)
|
||||
handler(boost::system::error_code ());
|
||||
m_Service.post (std::bind (&Stream::SendBuffer, shared_from_this ()));
|
||||
auto s = shared_from_this ();
|
||||
m_Service.post ([s, buffer]()
|
||||
{
|
||||
if (buffer)
|
||||
s->m_SendBuffer.Add (buffer);
|
||||
s->SendBuffer ();
|
||||
});
|
||||
}
|
||||
|
||||
void Stream::SendBuffer ()
|
||||
|
Loading…
Reference in New Issue
Block a user