diff --git a/lib/net/pool.js b/lib/net/pool.js index e6bcb178..77d0885d 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -352,6 +352,9 @@ Pool.prototype._disconnect = co(function* disconnect() { item.resolve(); } + // prevent peer list from trying to refill + this.disconnecting = true; + this.peers.destroy(); this.requestMap.reset(); @@ -374,6 +377,7 @@ Pool.prototype._disconnect = co(function* disconnect() { yield this.unlisten(); + this.disconnecting = false; this.syncing = false; this.connected = false; }); @@ -1152,6 +1156,9 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) { if (!outbound) return; + if(this.disconnecting) + return; + this.refill(); }); @@ -3720,11 +3727,6 @@ PeerList.prototype.has = function has(hostname) { PeerList.prototype.destroy = function destroy() { var peer, next; - this.map = {}; - this.load = null; - this.inbound = 0; - this.outbound = 0; - for (peer = this.list.head; peer; peer = next) { next = peer.next; peer.destroy();