diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-08-17 14:11:33 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-08-17 14:11:35 +0200 |
commit | 6c999fd2855f9bccf99666431cddc9b34930720b (patch) | |
tree | 54ab46e4448dc30634ca4002d18b88c80778d94c /lib/timers.js | |
parent | 05b3f88064a3dc85f892d0ff07dbca4f90437809 (diff) | |
download | node-new-6c999fd2855f9bccf99666431cddc9b34930720b.tar.gz |
timers: fix assertion in Timeout.unref()
Ensure that the delay >= 0 when detaching the timer from the queue. Fixes the
following assertion:
uv_timer_start: Assertion `timeout >= 0' failed.
No test included, it's timing sensitive.
Diffstat (limited to 'lib/timers.js')
-rw-r--r-- | lib/timers.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/timers.js b/lib/timers.js index 897b64f912..d281ea4061 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -253,10 +253,12 @@ var Timeout = function(after) { Timeout.prototype.unref = function() { if (!this._handle) { + var delay = this._when - Date.now(); + if (delay < 0) delay = 0; exports.unenroll(this); this._handle = new Timer(); this._handle.ontimeout = this._onTimeout; - this._handle.start(this._when - Date.now(), 0); + this._handle.start(delay, 0); this._handle.domain = this.domain; this._handle.unref(); } else { |