From 85830d50763542f96b1692428a935ab0b26b1bd6 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 27 Jan 2016 22:09:35 -0500 Subject: [PATCH] fixed race condtion #350 --- Transports.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Transports.cpp b/Transports.cpp index 98bd7bda..8d0ad4a6 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -69,20 +69,20 @@ namespace transport std::shared_ptr DHKeysPairSupplier::Acquire () { - if (!m_Queue.empty ()) { std::unique_lock l(m_AcquiredMutex); - auto pair = m_Queue.front (); - m_Queue.pop (); - m_Acquired.notify_one (); - return pair; + if (!m_Queue.empty ()) + { + auto pair = m_Queue.front (); + m_Queue.pop (); + m_Acquired.notify_one (); + return pair; + } } - else // queue is empty, create new - { - auto pair = std::make_shared (); - pair->GenerateKeys (); - return pair; - } + // queue is empty, create new + auto pair = std::make_shared (); + pair->GenerateKeys (); + return pair; } void DHKeysPairSupplier::Return (std::shared_ptr pair)