From 238cb25bb48a6d9282be2fbaf147cbd7d6997d84 Mon Sep 17 00:00:00 2001 From: ZeroNet Date: Wed, 10 Aug 2016 12:51:38 +0200 Subject: [PATCH] Small incoming connection optimization --- src/Connection/ConnectionServer.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index 95d67105..91d3e4e1 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -111,19 +111,19 @@ class ConnectionServer: raise Exception("Connection event return error") return connection - # Recover from connection pool - for connection in self.connections: - if connection.ip == ip: - if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match - continue - if ip.endswith(".onion") and self.tor_manager.start_onions and connection.site_lock != site.address: - # For different site - continue - if not connection.connected and create: - succ = connection.event_connected.get() # Wait for connection - if not succ: - raise Exception("Connection event return error") - return connection + # Recover from connection pool + for connection in self.connections: + if connection.ip == ip: + if peer_id and connection.handshake.get("peer_id") != peer_id: # Does not match + continue + if ip.endswith(".onion") and self.tor_manager.start_onions and connection.site_lock != site.address: + # For different site + continue + if not connection.connected and create: + succ = connection.event_connected.get() # Wait for connection + if not succ: + raise Exception("Connection event return error") + return connection # No connection found if create: # Allow to create new connection if not found