From: Tadas Varanavicius Date: Sat, 2 Feb 2013 15:29:32 +0000 (+0200) Subject: Abort timed out connections with abortConnection() X-Git-Tag: 11.2^2 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=19f0e6e0d9a7a491f3c92822d96e09ced452e2f4 Abort timed out connections with abortConnection() Timed out connections are not always killed with transport.loseConnection(). Call transport.abortConnection() instead. http://twistedmatrix.com/documents/12.2.0/core/howto/servers.html This fixes the memory leaking issues. --- diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 979b51e..f643b0c 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -80,7 +80,12 @@ class Protocol(p2protocol.Protocol): def _connect_timeout(self): self.timeout_delayed = None print 'Handshake timed out, disconnecting from %s:%i' % self.addr - self.transport.loseConnection() + if self.transport.abortConnection is not None: + # Available since Twisted 11.1 + self.transport.abortConnection() + else: + # This doesn't always close timed out connections! + self.transport.loseConnection() def packetReceived(self, command, payload2): try: @@ -101,7 +106,12 @@ class Protocol(p2protocol.Protocol): def _timeout(self): self.timeout_delayed = None print 'Connection timed out, disconnecting from %s:%i' % self.addr - self.transport.loseConnection() + if self.transport.abortConnection is not None: + # Available since Twisted 11.1 + self.transport.abortConnection() + else: + # This doesn't always close timed out connections! + self.transport.loseConnection() message_version = pack.ComposedType([ ('version', pack.IntType(32)),