From 501f5d21d344c56c78919fdf3bfa6604ed27b871 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 28 Mar 2016 19:19:05 -0700 Subject: [PATCH] On wire close, stop ut_pex sending interval This was a source of interval leaks --- lib/torrent.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index 3ff26a4c..eaa5396d 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -669,6 +669,11 @@ Torrent.prototype._onWire = function (wire, addr) { self.swarm.removePeer(peer) } }) + + wire.once('close', function () { + // Stop sending updates to remote peer + wire.ut_pex.reset() + }) } // Hook to allow user-defined `bittorrent-protocol` extensions @@ -724,7 +729,7 @@ Torrent.prototype._onWireWithMetadata = function (wire) { wire.unchoke() }) - wire.on('close', function () { + wire.once('close', function () { clearTimeout(timeoutId) })