Close extra outbound connections in BMConnectionPool.loop()
This commit is contained in:
parent
ab7c500a12
commit
4b8bd3bf9e
|
@ -282,12 +282,18 @@ class BMConnectionPool(object):
|
|||
)
|
||||
except ValueError:
|
||||
Proxy.onion_proxy = None
|
||||
established = sum(
|
||||
1 for c in self.outboundConnections.values()
|
||||
if (c.connected and c.fullyEstablished))
|
||||
pending = len(self.outboundConnections) - established
|
||||
if established < BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'maxoutboundconnections'):
|
||||
|
||||
established = [
|
||||
c for c in self.outboundConnections.values()
|
||||
if c.connected and c.fullyEstablished]
|
||||
established_num = len(established)
|
||||
pending = len(self.outboundConnections) - established_num
|
||||
excess = established_num - BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'maxoutboundconnections')
|
||||
if excess > 0:
|
||||
for _ in range(excess):
|
||||
established.pop().handle_close()
|
||||
else:
|
||||
for i in range(
|
||||
state.maximumNumberOfHalfOpenConnections - pending):
|
||||
try:
|
||||
|
|
Reference in New Issue
Block a user