@ -23,6 +23,8 @@ var Timer = process.binding('timer_wrap').Timer;
var L = require ( '_linklist' ) ;
var assert = require ( 'assert' ) . ok ;
var kOnTimeout = Timer . kOnTimeout | 0 ;
// Timeout values > TIMEOUT_MAX are set to 1.
var TIMEOUT_MAX = 2147483647 ; // 2^31-1
@ -62,7 +64,7 @@ function insert(item, msecs) {
lists [ msecs ] = list ;
list . msecs = msecs ;
list . ontimeout = listOnTimeout ;
list [ kOnTimeout ] = listOnTimeout ;
}
L . append ( list , item ) ;
@ -109,7 +111,7 @@ function listOnTimeout() {
} finally {
if ( threw ) {
process . nextTick ( function ( ) {
list . ontimeout ( ) ;
list [ kOnTimeout ] ( ) ;
} ) ;
}
}
@ -215,8 +217,8 @@ exports.setTimeout = function(callback, after) {
exports . clearTimeout = function ( timer ) {
if ( timer && ( timer . ontimeout || timer . _ onTimeout ) ) {
timer . ontimeout = timer . _ onTimeout = null ;
if ( timer && ( timer [ kOnTimeout ] || timer . _ onTimeout ) ) {
timer [ kOnTimeout ] = timer . _ onTimeout = null ;
if ( timer instanceof Timeout ) {
timer . close ( ) ; // for after === 0
} else {
@ -283,7 +285,7 @@ Timeout.prototype.unref = function() {
if ( delay < 0 ) delay = 0 ;
exports . unenroll ( this ) ;
this . _ handle = new Timer ( ) ;
this . _ handle . ontimeout = this . _ onTimeout ;
this . _ handle [ kOnTimeout ] = this . _ onTimeout ;
this . _ handle . start ( delay , 0 ) ;
this . _ handle . domain = this . domain ;
this . _ handle . unref ( ) ;
@ -300,7 +302,7 @@ Timeout.prototype.ref = function() {
Timeout . prototype . close = function ( ) {
this . _ onTimeout = null ;
if ( this . _ handle ) {
this . _ handle . ontimeout = null ;
this . _ handle [ kOnTimeout ] = null ;
this . _ handle . close ( ) ;
} else {
exports . unenroll ( this ) ;
@ -439,7 +441,7 @@ exports._unrefActive = function(item) {
unrefTimer = new Timer ( ) ;
unrefTimer . unref ( ) ;
unrefTimer . when = - 1 ;
unrefTimer . ontimeout = unrefTimeout ;
unrefTimer [ kOnTimeout ] = unrefTimeout ;
}
var now = Timer . now ( ) ;