From eddd99c77e7e4e9054a1168eb1dc40fc52d99233 Mon Sep 17 00:00:00 2001 From: Steve Kim <86316075+sbSteveK@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:02:06 -0700 Subject: [PATCH] Fix deadlock in destruction of Eventstream Client (#632) Co-authored-by: Bret Ambrose --- eventstream_rpc/source/EventStreamClient.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eventstream_rpc/source/EventStreamClient.cpp b/eventstream_rpc/source/EventStreamClient.cpp index d3c567853..ad5a9159b 100644 --- a/eventstream_rpc/source/EventStreamClient.cpp +++ b/eventstream_rpc/source/EventStreamClient.cpp @@ -321,6 +321,11 @@ namespace Aws { std::promise errorPromise; errorPromise.set_value({baseError, 0}); + if (baseError == EVENT_STREAM_RPC_NULL_PARAMETER) + { + const std::lock_guard lock(m_stateMutex); + m_clientState = DISCONNECTED; + } return errorPromise.get_future(); } @@ -353,6 +358,8 @@ namespace Aws "A CRT error occurred while attempting to establish the connection: %s", Crt::ErrorDebugString(crtError)); errorPromise.set_value({EVENT_STREAM_RPC_CRT_ERROR, crtError}); + const std::lock_guard lock(m_stateMutex); + m_clientState = DISCONNECTED; return errorPromise.get_future(); } else