diff --git a/cpp/src/DataStorm/SessionI.cpp b/cpp/src/DataStorm/SessionI.cpp index c1d9890044c..c4cea54eeba 100644 --- a/cpp/src/DataStorm/SessionI.cpp +++ b/cpp/src/DataStorm/SessionI.cpp @@ -630,13 +630,6 @@ SessionI::retry(NodePrx node, exception_ptr exception) { lock_guard lock(_mutex); - // Cancel any pending retry task, we are starting a new attempt. - if (_retryTask) - { - _instance->cancelTimerTask(_retryTask); - _retryTask = nullptr; - } - if (exception) { // Don't retry if we are shutting down. @@ -657,6 +650,13 @@ SessionI::retry(NodePrx node, exception_ptr exception) } } + // Cancel any pending retry task, before we start a new one below. + if (_retryTask) + { + _instance->cancelTimerTask(_retryTask); + _retryTask = nullptr; + } + if (node->ice_getEndpoints().empty() && node->ice_getAdapterId().empty()) { // We cannot retry because we don't have the peer endpoints. Wait twice the last retry interval for the peer to