diff options
Diffstat (limited to 'lib/conn-pool.js')
-rw-r--r-- | lib/conn-pool.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/conn-pool.js b/lib/conn-pool.js index 80aa87f..1ed49d9 100644 --- a/lib/conn-pool.js +++ b/lib/conn-pool.js @@ -1,4 +1,3 @@ -const arrayRemove = require('unordered-array-remove') const debug = require('debug')('webtorrent:conn-pool') const net = require('net') // browser exclude const utp = require('utp-native') // browser exclude @@ -23,7 +22,7 @@ class ConnPool { // Temporarily store incoming connections so they can be destroyed if the server is // closed before the connection is passed off to a Torrent. - this._pendingConns = [] + this._pendingConns = new Set() this._onTCPConnectionBound = (conn) => { this._onConnection(conn, 'tcp') @@ -129,7 +128,7 @@ class ConnPool { return } - self._pendingConns.push(conn) + self._pendingConns.add(conn) conn.once('close', cleanupPending) const peer = type === 'utp' ? Peer.createUTPIncomingPeer(conn) : Peer.createTCPIncomingPeer(conn) @@ -157,7 +156,7 @@ class ConnPool { conn.removeListener('close', cleanupPending) wire.removeListener('handshake', onHandshake) if (self._pendingConns) { - arrayRemove(self._pendingConns, self._pendingConns.indexOf(conn)) + self._pendingConns.delete(conn) } } } |