From a952d2d2c883a3c8ea30d4db3f45421ad3fab98d Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 23 May 2018 20:41:41 -0400 Subject: [PATCH] reset _listeningPort and _listening Deferred on teardown --- lbrynet/dht/node.py | 1 + lbrynet/dht/protocol.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index 1a6544ab1..363a9cd52 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -159,6 +159,7 @@ class Node(MockKademliaHelper): yield self.safe_stop_looping_call(self._change_token_lc) if self._listeningPort is not None: yield self._listeningPort.stopListening() + self._listeningPort = None def start_listening(self): if not self._listeningPort: diff --git a/lbrynet/dht/protocol.py b/lbrynet/dht/protocol.py index 9bd4a6b46..365360339 100644 --- a/lbrynet/dht/protocol.py +++ b/lbrynet/dht/protocol.py @@ -171,6 +171,8 @@ class KademliaProtocol(protocol.DatagramProtocol): def startProtocol(self): log.info("DHT listening on UDP %s:%i", self._node.externalIP, self._node.port) + if self._listening.called: + self._listening = defer.Deferred() self._listening.callback(True) return self._ping_queue.start()