diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-21 09:00:00 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | e9787803231bd9b6debe9baa3649e55ce882b393 (patch) | |
tree | bd3dc5a2850115cde044b444781c6b71a41e7d49 | |
parent | 40510daeca17b3db2cad0c9101d8f513df7127d1 (diff) |
Do not put infinitely when there are no other subscribers
-rw-r--r-- | src/BootstrapConnection.cpp | 12 |
1 files 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::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); if(now - listenStartTimeMs > half_min_ms) |