From 4f84a5d325686202bd623ee530d197596ff3f411 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 21 Oct 2018 10:10:25 +0200 Subject: Stop put if cancel is called --- src/BootstrapConnection.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index a9ff5b8..f74129b 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -194,10 +194,12 @@ namespace sibs it->second.listenCallbackFunc = callbackFunc; return { pubsubKey }; } - auto &data = subscribeData[pubsubKey]; + + SubscribeData data; if(registerCallbackFunc) data.listenCallbackFunc = callbackFunc; data.listenStartTimeMs = chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); + subscribeData[pubsubKey] = data; } auto message = std::make_shared(MessageType::SUBSCRIBE); @@ -250,8 +252,8 @@ namespace sibs auto subscribeIt = subscribeData.find(pubsubKey); if(subscribeIt == subscribeData.end()) { - Log::warn("BootstrapConnection::put with no subscribers on same key '%s'", pubsubKey.toString().c_str()); - goto checkPutAttemptDuration; + Log::warn("BootstrapConnection::put: listen cancelled for '%s', stopping put attempts", pubsubKey.toString().c_str()); + break; } listenStartTimeMs = subscribeIt->second.listenStartTimeMs; @@ -275,7 +277,6 @@ namespace sibs peersToMessage.clear(); } - checkPutAttemptDuration: const i64 half_min_ms = 1000 * 30; i64 now = chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); if(now - listenStartTimeMs > half_min_ms) -- cgit v1.2.3