mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 01:46:36 +02:00
unlock mutex for good after wait
This commit is contained in:
parent
cb139226df
commit
3e3e2c41bd
1 changed files with 6 additions and 4 deletions
|
@ -481,7 +481,6 @@ namespace stream
|
|||
volatile bool done = false;
|
||||
std::condition_variable newDataReceived;
|
||||
std::mutex newDataReceivedMutex;
|
||||
std::unique_lock<std::mutex> l(newDataReceivedMutex);
|
||||
AsyncReceive (boost::asio::buffer (buf, len),
|
||||
[&ret, &done, &newDataReceived, &newDataReceivedMutex](const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||
{
|
||||
|
@ -490,12 +489,15 @@ namespace stream
|
|||
else
|
||||
ret = bytes_transferred;
|
||||
std::unique_lock<std::mutex> l(newDataReceivedMutex);
|
||||
done = true;
|
||||
newDataReceived.notify_all ();
|
||||
done = true;
|
||||
},
|
||||
timeout);
|
||||
if (newDataReceived.wait_for (l, std::chrono::seconds (timeout)) == std::cv_status::timeout)
|
||||
ret = 0;
|
||||
if (!done)
|
||||
{ std::unique_lock<std::mutex> l(newDataReceivedMutex);
|
||||
if (!done && newDataReceived.wait_for (l, std::chrono::seconds (timeout)) == std::cv_status::timeout)
|
||||
ret = 0;
|
||||
}
|
||||
if (!done)
|
||||
{
|
||||
// make sure that AsycReceive complete
|
||||
|
|
Loading…
Add table
Reference in a new issue