diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-21 10:10:25 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | 4f84a5d325686202bd623ee530d197596ff3f411 (patch) | |
tree | d3e5d8266270d8e2e568d3bbb9659ba988b2886b /src | |
parent | 014fd4f91d97db4d65931fc6aef90794591ff85f (diff) |
Stop put if cancel is called
Diffstat (limited to 'src')
-rw-r--r-- | src/BootstrapConnection.cpp | 9 |
1 files 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::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); + subscribeData[pubsubKey] = data; } auto message = std::make_shared<Message>(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::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); if(now - listenStartTimeMs > half_min_ms) |