From 3e393d5a001bf08c6e2acbc1713005e1e1470895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 20 Sep 2021 10:43:37 -0400 Subject: [PATCH] manager: shutdown connections before unregistering accounts shutdownConnections is only called when the account is disabled to avoid to call it if the account's config is changed. However, when stopping the daemon, doUnregister is called if the account is enabled, and this should also call shutdownConnections() to avoid any lock. Change-Id: I35fba66b1b7f86360fa29cbeec78697f2b7c3328 --- src/jamidht/jamiaccount.cpp | 1 + src/manager.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 36793772e3..a7e53ca657 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2546,6 +2546,7 @@ JamiAccount::doUnregister(std::function<void(bool)> released_cb) // Stop all current p2p connections if account is disabled // Else, we let the system managing if the co is down or not + // NOTE: this is used for changing account's config. if (not isEnabled()) shutdownConnections(); diff --git a/src/manager.cpp b/src/manager.cpp index d7a7ec6abe..db87e72ede 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -997,8 +997,13 @@ void Manager::unregisterAccounts() { for (const auto& account : getAllAccounts()) { - if (account->isEnabled()) + if (account->isEnabled()) { + if (auto acc = std::dynamic_pointer_cast<JamiAccount>(account)) { + // Note: shutdown the connections as doUnregister will not do it (because the account is enabled) + acc->shutdownConnections(); + } account->doUnregister(); + } } } -- GitLab