Fix: refuse connect when reach max connections. [skip travis]
@@ -734,6 +734,18 @@ impl PendingConnectedNodeReq {
}
pub fn handle(self, service: &mut NodesManager) {
+ if service.connected_addrs.len() >= service.max_connects {
+ // Has reach to max connects, refuse this connection
+ info!(
+ "[NodeManager] Has reach to max connections [{:?}], refuse Session [{:?}], address: {:?}",
+ service.max_connects, self.session_id, self.addr
+ );
+ if let Some(ref mut ctrl) = service.service_ctrl {
+ let _ = ctrl.disconnect(self.session_id);
+ }
+ return;
+ }
+
info!(
"[NodeManager] Session [{:?}], address: {:?} pending to add to Connected_addrs.",
self.session_id, self.addr
