diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 4a2cc4ae..7523b939 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2022, The PurpleI2P Project +* Copyright (c) 2013-2023, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -1138,19 +1138,25 @@ namespace client template std::shared_ptr ClientDestination::CreateStreamSync (const Dest& dest, int port) { + volatile bool done = false; std::shared_ptr stream; std::condition_variable streamRequestComplete; std::mutex streamRequestCompleteMutex; - std::unique_lock l(streamRequestCompleteMutex); CreateStream ( - [&streamRequestComplete, &streamRequestCompleteMutex, &stream](std::shared_ptr s) + [&done, &streamRequestComplete, &streamRequestCompleteMutex, &stream](std::shared_ptr s) { stream = s; std::unique_lock l(streamRequestCompleteMutex); streamRequestComplete.notify_all (); + done = true; }, dest, port); - streamRequestComplete.wait (l); + while (!done) + { + std::unique_lock l(streamRequestCompleteMutex); + if (!done) + streamRequestComplete.wait (l); + } return stream; }