aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-21 09:00:00 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-21 09:00:03 +0200
commita5686d8c2744d8cdfdcfab9c5de50e9e781043c9 (patch)
treef54baa928a756ab993e33957b8d6aa26b392dd3a
parente81aea0fc96a2eb44e09d3aa0aad1e7d11878cae (diff)
Do not put infinitely when there are no other subscribers
-rw-r--r--src/BootstrapConnection.cpp12
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)