From de36d64d4a07fbe05d9596bd83bf332ee3fddaad Mon Sep 17 00:00:00 2001 From: Mokhtar Naamani Date: Thu, 26 Jan 2017 18:19:55 +0200 Subject: [PATCH] pool: graceful disconnect --- lib/net/pool.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/net/pool.js b/lib/net/pool.js index e6bcb178..d918d5a1 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -354,6 +354,8 @@ Pool.prototype._disconnect = co(function* disconnect() { this.peers.destroy(); + this.nonces = new NonceList(); + this.requestMap.reset(); if (this.pendingFilter != null) { @@ -3727,8 +3729,15 @@ PeerList.prototype.destroy = function destroy() { for (peer = this.list.head; peer; peer = next) { next = peer.next; + + // stop processing peer events + peer.onPacket = null; + peer.removeAllListeners() + peer.destroy(); } + + this.list = new List(); }; /**