From: Forrest Voight Date: Sat, 4 Feb 2012 19:49:34 +0000 (-0500) Subject: made p2p timeout reset on received data instead of entire received message, so that... X-Git-Tag: 0.8.4~31 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=4b7e82a32c755964b2768510cf24ad1777351e5e;p=p2pool.git made p2p timeout reset on received data instead of entire received message, so that slow connections don't always time out --- diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 859e884..983d9f6 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -57,6 +57,9 @@ class Protocol(bitcoin_p2p.BaseProtocol): reactor.callLater(10, self._connect_timeout) self.timeout_delayed = reactor.callLater(100, self._timeout) + + old_dataReceived = self.dataReceived + self.dataReceived = lambda data: (self.timeout_delayed.reset(100) if not self.timeout_delayed.called else None, old_dataReceived(data))[0] def _connect_timeout(self): if not self.connected2 and self.transport.connected: @@ -68,10 +71,6 @@ class Protocol(bitcoin_p2p.BaseProtocol): self.transport.loseConnection() return - if not self.timeout_delayed.called: - self.timeout_delayed.cancel() - self.timeout_delayed = reactor.callLater(100, self._timeout) - bitcoin_p2p.BaseProtocol.packetReceived(self, command, payload2) def _timeout(self):