timers: assure setTimeout callback only runs once
authorRoman Reiss <me@silverwind.io>
Sat, 21 Mar 2015 16:39:35 +0000 (17:39 +0100)
committerRoman Reiss <me@silverwind.io>
Thu, 26 Mar 2015 16:31:20 +0000 (17:31 +0100)
commitcaf0b36de33ad4991e3f21ed088a84c68cb0662d
tree454cf78b27bec9591c8b133e96bb066d31126cbe
parent2ccc8f3970cd1ed78585be37c8d912f3ccf56cd0
timers: assure setTimeout callback only runs once

Calling this.unref() during the callback of SetTimeout caused the
callback to get executed twice because unref() didn't expect to be
called during that time and did not stop the ref()ed Timeout but
did start a new timer. This commit prevents the new timer creation
when the callback was already called.

Fixes: https://github.com/iojs/io.js/issues/1191
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
PR-URL: https://github.com/iojs/io.js/pull/1231
lib/timers.js
test/parallel/test-timers-unref.js