Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call unref only when present #630

Merged
merged 1 commit into from Feb 21, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -383,10 +383,10 @@ function runDownload (torrentId) {
var vlcPath = item.value + path.sep + 'vlc'
VLC_ARGS = VLC_ARGS.split(' ')
VLC_ARGS.unshift(href)
cp.execFile(vlcPath, VLC_ARGS, function (err) {
unref(cp.execFile(vlcPath, VLC_ARGS, function (err) {
if (err) return fatalError(err)
torrentDone()
}).unref()
}))
})
}
} else if (argv.vlc) {
@@ -404,10 +404,10 @@ function runDownload (torrentId) {
}

if (cmd) {
cp.exec(cmd, function (err) {
unref(cp.exec(cmd, function (err) {
if (err) return fatalError(err)
torrentDone()
}).unref()
}))
}

if (argv.airplay) {
@@ -467,7 +467,7 @@ function drawTorrent (torrent) {
if (!argv.quiet) {
process.stdout.write(new Buffer('G1tIG1sySg==', 'base64')) // clear for drawing
drawInterval = setInterval(draw, 500)
drawInterval.unref()
unref(drawInterval)
}

function draw () {
@@ -573,7 +573,7 @@ function drawTorrent (torrent) {
}

function torrentDone () {
if (argv['on-done']) cp.exec(argv['on-done']).unref()
if (argv['on-done']) unref(cp.exec(argv['on-done']))
if (!playerName && !serving && argv.out) gracefulExit()
}

@@ -597,13 +597,17 @@ function gracefulExit () {

if (!client) return

if (argv['on-exit']) cp.exec(argv['on-exit']).unref()
if (argv['on-exit']) unref(cp.exec(argv['on-exit']))

client.destroy(function (err) {
if (err) return fatalError(err)

// Quit after 1 second. This is only necessary for `webtorrent-hybrid` since
// the `wrtc` package makes node never quit :(
setTimeout(function () { process.exit(0) }, 1000).unref()
unref(setTimeout(function () { process.exit(0) }, 1000))
})
}

function unref (iv) {
if (iv && typeof iv.unref === 'function') iv.unref()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.