lib: fix guard expression in timer.unref()
authorBen Noordhuis <info@bnoordhuis.nl>
Mon, 15 Dec 2014 16:25:31 +0000 (17:25 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 18 Dec 2014 17:24:29 +0000 (18:24 +0100)
commitebf9f297b30d6cf2e5060da91d63cebbedc448e2
treed94a7af32c76315542ab6463a4ed8f7e1ac5bd57
parentb7d247856e318a830eff7e2d12495008c1c80ae3
lib: fix guard expression in timer.unref()

Fixes the following assertion on slow systems, like our ARM buildbot:

    $ out/Debug/node test/simple/test-timers-unref.js
    node: ../src/async-wrap-inl.h:101: v8::Handle<v8::Value>
    node::AsyncWrap::MakeCallback(uint32_t, int,
    v8::Handle<v8::Value>*): Assertion `cb_v->IsFunction()' failed.
    Aborted

The reason it only manifests on slow systems is that the test starts
a 1 ms interval timer, then defers timer.unref.bind({}) to the next
tick.  On fast systems, the test completes in under a millisecond,
before the callback is called.

This commit makes timer.unref() check that the receiver actually has
a timeout callback property.

Fixes #13.

PR-URL: https://github.com/iojs/io.js/pull/165
Reviewed-By: Rod Vagg <rod@vagg.org>
lib/timers.js
test/parallel/test-timers-unref-call.js [new file with mode: 0644]