From e9787803231bd9b6debe9baa3649e55ce882b393 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 21 Oct 2018 09:00:00 +0200 Subject: Do not put infinitely when there are no other subscribers --- src/BootstrapConnection.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index f83b21c..55e49df 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -252,17 +252,18 @@ namespace sibs { Log::warn("BootstrapConnection::put with no subscribers on same key '%s'", pubsubKey.toString().c_str()); std::this_thread::sleep_for(std::chrono::milliseconds(200)); - continue; + goto checkPutAttemptDuration; } listenStartTimeMs = subscribeIt->second.listenStartTimeMs; for(auto &peer : subscribeIt->second.peers) { - if(peersMessaged.find(peer->socket->udtSocket) != peersMessaged.end()) - continue; - peersToMessage.push_back(peer); - peersMessaged.insert(peer->socket->udtSocket); + if(peersMessaged.find(peer->socket->udtSocket) == peersMessaged.end()) + { + peersToMessage.push_back(peer); + peersMessaged.insert(peer->socket->udtSocket); + } } } @@ -275,6 +276,7 @@ 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