mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-19 04:31:36 +00:00
Time out and clean up udp stopped messages
This solves one of the problems with the bittorrent-client tests not exiting
This commit is contained in:
parent
575f28e041
commit
48baf2bfa6
9
index.js
9
index.js
@ -172,15 +172,16 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
|
|||||||
var socket = dgram.createSocket('udp4')
|
var socket = dgram.createSocket('udp4')
|
||||||
var transactionId = new Buffer(hat(32), 'hex')
|
var transactionId = new Buffer(hat(32), 'hex')
|
||||||
|
|
||||||
if (opts.event !== 'stopped') {
|
var stopped = opts.event === 'stopped'
|
||||||
// if we're sending a stopped message, we don't really care if it arrives, so don't
|
// if we're sending a stopped message, we don't really care if it arrives, so set
|
||||||
// set a timer
|
// a short timer and don't call error
|
||||||
var timeout = setTimeout(function () {
|
var timeout = setTimeout(function () {
|
||||||
timeout = null
|
timeout = null
|
||||||
cleanup()
|
cleanup()
|
||||||
|
if (!stopped) {
|
||||||
error('tracker request timed out')
|
error('tracker request timed out')
|
||||||
}, 15000)
|
|
||||||
}
|
}
|
||||||
|
}, stopped ? 1500 : 15000)
|
||||||
|
|
||||||
if (timeout && timeout.unref) {
|
if (timeout && timeout.unref) {
|
||||||
timeout.unref()
|
timeout.unref()
|
||||||
|
Loading…
Reference in New Issue
Block a user