From 89b7ffe91f2740523ace94b9a25b9d74e1bd61e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 18 Jan 2022 15:41:50 -0500 Subject: [PATCH] jamiaccount: avoid to block in doUnregister if ERROR_GENERIC If the account is incorrectly registered (i.e. the common case is that the DHT socket is not correctly initialized), setRegistrationState(RegistrationState::ERROR_GENERIC) will be called and the dht will not be usable. Calling doUnregister will cause the daemon to block on dht_->shutdown(). Because the account is not ready to be used, doUnregister() should do nothing if any error happened during the registration. Also, removes 2 unused states. Change-Id: I0393786afea8c13506c7c87caf265b09182ea0ae --- src/account.cpp | 2 -- src/jamidht/jamiaccount.cpp | 4 +--- src/registration_states.h | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/account.cpp b/src/account.cpp index 389312a9ec..f24d1f1bc0 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -448,8 +448,6 @@ Account::mapStateNumberToString(RegistrationState state) CASE_STATE(ERROR_NETWORK); CASE_STATE(ERROR_HOST); CASE_STATE(ERROR_SERVICE_UNAVAILABLE); - CASE_STATE(ERROR_EXIST_STUN); - CASE_STATE(ERROR_NOT_ACCEPTABLE); CASE_STATE(ERROR_NEED_MIGRATION); CASE_STATE(INITIALIZING); default: diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index aa11d4a876..cab84c4792 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2347,9 +2347,7 @@ void JamiAccount::doUnregister(std::function<void(bool)> released_cb) { std::unique_lock<std::recursive_mutex> lock(configurationMutex_); - - if (registrationState_ == RegistrationState::INITIALIZING - || registrationState_ == RegistrationState::ERROR_NEED_MIGRATION) { + if (registrationState_ >= RegistrationState::ERROR_GENERIC) { lock.unlock(); if (released_cb) released_cb(false); diff --git a/src/registration_states.h b/src/registration_states.h index abc66a6e96..d4c4aa248e 100644 --- a/src/registration_states.h +++ b/src/registration_states.h @@ -38,8 +38,6 @@ enum class RegistrationState { ERROR_NETWORK, ERROR_HOST, ERROR_SERVICE_UNAVAILABLE, - ERROR_EXIST_STUN, - ERROR_NOT_ACCEPTABLE, ERROR_NEED_MIGRATION, INITIALIZING }; -- GitLab