Commit f038fe78 authored by Adrien Béraud's avatar Adrien Béraud

jamiaccount: lock doRegister

Change-Id: Ifa4bc41febb2149abd14fe8f4f30bb8e93bf9bb2
parent 4357af81
...@@ -1651,8 +1651,10 @@ void ...@@ -1651,8 +1651,10 @@ void
JamiAccount::registerAsyncOps() JamiAccount::registerAsyncOps()
{ {
auto onLoad = [this, loaded = std::make_shared<std::atomic_uint>()]{ auto onLoad = [this, loaded = std::make_shared<std::atomic_uint>()]{
if (++(*loaded) == 2u) if (++(*loaded) == 2u) {
std::lock_guard<std::mutex> lock(configurationMutex_);
doRegister_(); doRegister_();
}
}; };
loadCachedProxyServer([onLoad](const std::string&) { loadCachedProxyServer([onLoad](const std::string&) {
...@@ -1684,6 +1686,7 @@ JamiAccount::registerAsyncOps() ...@@ -1684,6 +1686,7 @@ JamiAccount::registerAsyncOps()
void void
JamiAccount::doRegister() JamiAccount::doRegister()
{ {
std::lock_guard<std::mutex> lock(configurationMutex_);
if (not isUsable()) { if (not isUsable()) {
JAMI_WARN("Account must be enabled and active to register, ignoring"); JAMI_WARN("Account must be enabled and active to register, ignoring");
return; return;
...@@ -1848,8 +1851,6 @@ JamiAccount::onTrackedBuddyOffline(const dht::InfoHash& contactId) ...@@ -1848,8 +1851,6 @@ JamiAccount::onTrackedBuddyOffline(const dht::InfoHash& contactId)
void void
JamiAccount::doRegister_() JamiAccount::doRegister_()
{ {
std::lock_guard<std::mutex> lock(configurationMutex_);
if (registrationState_ != RegistrationState::TRYING) { if (registrationState_ != RegistrationState::TRYING) {
JAMI_ERR("[Account %s] already registered", getAccountID().c_str()); JAMI_ERR("[Account %s] already registered", getAccountID().c_str());
return; return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment