fixed issue where an erroneous tracker could cause webtorrent to crash because socket.close was already closed after an error state

This commit is contained in:
fisch0920 2014-05-15 06:29:47 -04:00
parent 50d3379255
commit c4684c8b72

View File

@ -180,13 +180,11 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
function error (message) {
self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')'))
socket.close()
try { socket.close() } catch (e) { }
clearTimeout(timeout)
}
socket.on('error', function (err) {
error(err)
})
socket.on('error', error)
socket.on('message', function (message, rinfo) {