Skip to content
Snippets Groups Projects
Commit 0df69a32 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

Merge branch 'master' of gitlab.utu.fi:nicolas.pope/ftl

parents 1051eebf e2027c94
No related branches found
No related tags found
No related merge requests found
Pipeline #12393 passed
......@@ -216,6 +216,7 @@ class Universe : public ftl::Configurable {
ftl::net::Dispatcher disp_;
std::thread thread_;
std::list<ReconnectInfo> reconnects_;
size_t phase_;
struct ConnHandler {
callback_t id;
......
......@@ -24,12 +24,12 @@ using ftl::net::callback_t;
callback_t ftl::net::Universe::cbid__ = 0;
Universe::Universe() : Configurable(), active_(true), this_peer(ftl::net::this_peer), thread_(Universe::__start, this) {
Universe::Universe() : Configurable(), active_(true), this_peer(ftl::net::this_peer), thread_(Universe::__start, this), phase_(0) {
_installBindings();
}
Universe::Universe(nlohmann::json &config) :
Configurable(config), active_(true), this_peer(ftl::net::this_peer), thread_(Universe::__start, this) {
Configurable(config), active_(true), this_peer(ftl::net::this_peer), thread_(Universe::__start, this), phase_(0) {
_installBindings();
}
......@@ -305,7 +305,9 @@ void Universe::_run() {
SHARED_LOCK(net_mutex_, lk);
// Also check each clients socket to see if any messages or errors are waiting
for (auto s : peers_) {
for (size_t p=0; p<peers_.size(); ++p) {
auto s = peers_[(p+phase_)%peers_.size()];
if (s != NULL && s->isValid()) {
// Note: It is possible that the socket becomes invalid after check but before
// looking at the FD sets, therefore cache the original socket
......@@ -323,6 +325,7 @@ void Universe::_run() {
}
}
}
++phase_;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment