mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
do not access socket.infoHashes if socket is destroyed
This commit is contained in:
parent
40707a1605
commit
b2c2b8f0d0
@ -102,7 +102,7 @@ Swarm.prototype._onAnnounceStopped = function (params, peer, id) {
|
||||
|
||||
// If it's a websocket, remove this swarm's infohash from the list of active
|
||||
// swarms that this peer is participating in.
|
||||
if (peer.socket) {
|
||||
if (peer.socket && !peer.socket.destroyed) {
|
||||
var index = peer.socket.infoHashes.indexOf(this.infoHash)
|
||||
arrayRemove(peer.socket.infoHashes, index)
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ Server.prototype._onWebSocketRequest = function (socket, opts, params) {
|
||||
if (!socket.peerId) socket.peerId = params.peer_id // as hex
|
||||
|
||||
self._onRequest(params, function (err, response) {
|
||||
if (self.destroyed) return
|
||||
if (self.destroyed || socket.destroyed) return
|
||||
if (err) {
|
||||
socket.send(JSON.stringify({
|
||||
action: params.action === common.ACTIONS.ANNOUNCE ? 'announce' : 'scrape',
|
||||
@ -587,6 +587,7 @@ Server.prototype._onWebSocketSend = function (socket, err) {
|
||||
Server.prototype._onWebSocketClose = function (socket) {
|
||||
var self = this
|
||||
debug('websocket close %s', socket.peerId)
|
||||
socket.destroyed = true
|
||||
|
||||
if (socket.peerId) {
|
||||
socket.infoHashes.slice(0).forEach(function (infoHash) {
|
||||
|
Loading…
Reference in New Issue
Block a user