timers: reuse timer in `setTimeout().unref()`
authorFedor Indutny <fedor@indutny.com>
Fri, 16 Oct 2015 19:34:15 +0000 (15:34 -0400)
committerJames M Snell <jasnell@gmail.com>
Thu, 29 Oct 2015 15:38:44 +0000 (08:38 -0700)
commit8d78d687d5c5eec3ea1f171f9e85664c0b0bc97f
treeece0c3aec19c1056b9e98739cc0b11119f0116c7
parent7cad182cb60b6774fd07750f68aa37f5513a6b52
timers: reuse timer in `setTimeout().unref()`

Instead of creating new timer - reuse the timer from the freelist. This
won't make the freelist timer active for the duration of `uv_close()`,
and will let the event-loop exit properly.

Fix: #1264
PR-URL: https://github.com/nodejs/node/pull/3407
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
lib/timers.js
test/parallel/test-timers-unrefed-in-beforeexit.js [new file with mode: 0644]