From 792b18e6e9916084752899fb86e1f1b50343320d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 22 Oct 2024 23:42:20 -0400 Subject: [PATCH] ConnectionManager: avoid handling shutdown twice Only process the callback if it was not already done by the tls shutdown callback. Change-Id: Iee9b479100268c4815f40f7b5d51b9db7dbb22cd --- src/connectionmanager.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp index a341b95..45dc64c 100644 --- a/src/connectionmanager.cpp +++ b/src/connectionmanager.cpp @@ -980,15 +980,16 @@ ConnectionManager::Impl::startConnection(const std::shared_ptr<DeviceInfo>& di, auto eraseInfo = [w = weak_from_this(), diw=std::weak_ptr(di), vid] { if (auto di = diw.lock()) { std::unique_lock lk(di->mutex_); - di->info.erase(vid); - auto ops = di->extractPendingOperations(vid, nullptr); - if (di->empty()) { - if (auto shared = w.lock()) - shared->infos_.removeDeviceInfo(di->deviceId); + if (di->info.erase(vid)) { + auto ops = di->extractPendingOperations(vid, nullptr); + if (di->empty()) { + if (auto shared = w.lock()) + shared->infos_.removeDeviceInfo(di->deviceId); + } + lk.unlock(); + for (const auto& op: ops) + op.cb(nullptr, di->deviceId); } - lk.unlock(); - for (const auto& op: ops) - op.cb(nullptr, di->deviceId); } }; -- GitLab