summaryrefslogtreecommitdiff
path: root/lib/timers.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-08-17 14:11:33 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2012-08-17 14:11:35 +0200
commit6c999fd2855f9bccf99666431cddc9b34930720b (patch)
tree54ab46e4448dc30634ca4002d18b88c80778d94c /lib/timers.js
parent05b3f88064a3dc85f892d0ff07dbca4f90437809 (diff)
downloadnode-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.js4
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 {