timers: do not restart the interval after close
authorFedor Indutny <fedor@indutny.com>
Thu, 2 Apr 2015 22:14:08 +0000 (01:14 +0300)
committerFedor Indutny <fedor@indutny.com>
Fri, 3 Apr 2015 23:31:47 +0000 (02:31 +0300)
commitd22b2a934a62087522511e1e6b66b71370506c77
tree06178bc4e397910a2c9a76e5822d0a5217111a79
parentcca5efb086b0c9d0e78be3ce0b9690f16e6f0ad9
timers: do not restart the interval after close

Partially revert 776b73b24306bac0ce299df4f90b7645d5efca31.

Following code crashes after backported timer leak fixes:

```javascript
var timer = setInterval(function() {
  clearInterval(timer);
}, 10);
timer.unref();
```

Note that this is actually tested in a `test-timers-unref.js`, and is
crashing only with 776b73b24306bac0ce299df4f90b7645d5efca31.

Calling `clearInterval` leads to the crashes in case of `.unref()`ed
timers, and might lead to a extra timer spin in case of regular
intervals that was closed during the interval callback. All of these
happens because `.unref()`ed timer has it's own `_handle` and was used
after the `.close()`.

PR-URL: https://github.com/iojs/io.js/pull/1330
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
lib/timers.js
src/timer_wrap.cc