diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 30e4e1de53bf66813df83414eadd73bd5aca6871..a17b5899810556e3607d87d0d3b5f02246818faa 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -2139,10 +2139,14 @@ RingAccount::doRegister_() }); #endif - dht_.setOnStatusChanged([this](dht::NodeStatus s4, dht::NodeStatus s6) { + auto currentDhtStatus = std::make_shared<dht::NodeStatus>(dht::NodeStatus::Disconnected); + dht_.setOnStatusChanged([this, currentDhtStatus](dht::NodeStatus s4, dht::NodeStatus s6) { RING_DBG("[Account %s] Dht status : IPv4 %s; IPv6 %s", getAccountID().c_str(), dhtStatusStr(s4), dhtStatusStr(s6)); RegistrationState state; - switch (std::max(s4, s6)) { + auto newStatus = std::max(s4, s6); + if (newStatus == *currentDhtStatus) + return; + switch (newStatus) { case dht::NodeStatus::Connecting: RING_WARN("[Account %s] connecting to the DHT network...", getAccountID().c_str()); state = RegistrationState::TRYING; @@ -2159,6 +2163,7 @@ RingAccount::doRegister_() state = RegistrationState::ERROR_GENERIC; break; } + *currentDhtStatus = newStatus; setRegistrationState(state); });