diff --git a/src/peer.cpp b/src/peer.cpp index b248217734aec3578b3b76abd7d2f57a70c50be2..4ff16f1a726349029844227a3fb7e2837427a990 100644 --- a/src/peer.cpp +++ b/src/peer.cpp @@ -271,6 +271,7 @@ void Peer::data() { if (rc >= cap - 1) { net_->_notifyError(this, ftl::protocol::Error::kBufferSize, "Too much data received"); + // TODO: Increase the buffer size next time } if (cap < (kMaxMessage / 10)) { net_->_notifyError(this, ftl::protocol::Error::kBufferSize, "Buffer is at capacity"); diff --git a/src/universe.cpp b/src/universe.cpp index f31551cfc47c40d71f2947b1d11acbb9ec777173..0ce3da3afc906262bf45c271c1278ad58aec71a4 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -361,9 +361,6 @@ void Universe::_removePeer(PeerPtr &p) { p->status() == NodeStatus::kReconnecting || p->status() == NodeStatus::kDisconnected)) { - DLOG(1) << "Removing disconnected peer: " << p->id().to_string(); - on_disconnect_.triggerAsync(p); - auto ix = peer_ids_.find(p->id()); if (ix != peer_ids_.end()) peer_ids_.erase(ix); @@ -381,6 +378,10 @@ void Universe::_removePeer(PeerPtr &p) { } --connection_count_; + + DLOG(1) << "Removing disconnected peer: " << p->id().to_string(); + on_disconnect_.triggerAsync(p); + p.reset(); } } @@ -396,9 +397,8 @@ void Universe::_cleanupPeers() { lk.unlock(); _removePeer(p); lk.lock(); - } else { - i++; } + ++i; } } @@ -573,19 +573,19 @@ void Universe::_run() { const auto &fdstruct = impl_->pollfds[impl_->idMap[sock]]; - if (fdstruct.revents & POLLERR) { + /*if (fdstruct.revents & POLLERR) { if (s->socketError()) { //lk.unlock(); s->close(); //lk.lock(); continue; // No point in reading data... } - } + }*/ //If message received from this client then deal with it if (fdstruct.revents & POLLIN) { - //lk.unlock(); + lk.unlock(); s->data(); - //lk.lock(); + lk.lock(); } } }