Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJames Halliday <mail@substack.net>2016-02-20 06:21:06 +0300
committerJames Halliday <mail@substack.net>2016-02-20 06:21:31 +0300
commite8634ac4a7235d01c2c05a06dacb36199046e3c4 (patch)
tree3d3705e5015e15516208c1ab396f544eda48e83a /bin
parent1ef81384dcab01800f14cf620171762091897735 (diff)
call unref only when present
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 94817fd..078cc84 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -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()
+}