From a95fcf5693edb92c99894abb8708b3427794cdc1 Mon Sep 17 00:00:00 2001 From: Stanislav Angelovic Date: Thu, 22 Jul 2021 13:48:40 +0200 Subject: [PATCH] Make resetting loop thread ID exception-safe --- src/Connection.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Connection.cpp b/src/Connection.cpp index 12c3b00..b4067d9 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -92,6 +92,7 @@ std::string Connection::getUniqueName() const void Connection::enterEventLoop() { loopThreadId_ = std::this_thread::get_id(); + SCOPE_EXIT{ loopThreadId_ = std::thread::id{}; }; std::lock_guard guard(loopMutex_); @@ -105,8 +106,6 @@ void Connection::enterEventLoop() if (!success) break; // Exit I/O event loop } - - loopThreadId_ = std::thread::id{}; } void Connection::enterEventLoopAsync()