aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-21 10:10:25 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-21 10:10:26 +0200
commitf0a2053c2b44298a8cf1aacbafb29870ed521aa0 (patch)
tree53f66ccf3700327cb87b95b63cd0ec199c5ddc53
parent2b0259c00198181a267884144472e433d6195ef8 (diff)
Stop put if cancel is called
-rw-r--r--src/BootstrapConnection.cpp9
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)