summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKyle Simpson <getify@gmail.com>2015-08-22 13:46:36 -0500
committerRich Trott <rtrott@gmail.com>2016-03-28 16:18:14 -0700
commit9fa25c8ca0158fec7526c7b8b3db74d2bc66fb73 (patch)
tree08b2aa8e421acd2f923391a85abedbe909ba50cd /lib
parenta17200b520919a20f72b3353974de82684168b35 (diff)
downloadandroid-node-v8-9fa25c8ca0158fec7526c7b8b3db74d2bc66fb73.tar.gz
android-node-v8-9fa25c8ca0158fec7526c7b8b3db74d2bc66fb73.tar.bz2
android-node-v8-9fa25c8ca0158fec7526c7b8b3db74d2bc66fb73.zip
timers: fixing API refs to use safe internal refs
Added safe internal references for 'clearTimeout(..)', 'active(..)', and 'unenroll(..)'. Changed various API refs from 'export.*' to use these safe internal references. Now, overwriting the global API identifiers does not create potential breakage and/or race conditions. See Issue #2493. PR-URL: https://github.com/nodejs/node/pull/5882 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Fixes: https://github.com/nodejs/node/issues/2493
Diffstat (limited to 'lib')
-rw-r--r--lib/timers.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/timers.js b/lib/timers.js
index 478a054339..dc2506e01e 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -100,7 +100,7 @@ const unrefedLists = {};
// Schedule or re-schedule a timer.
// The item must have been enroll()'d first.
-exports.active = function(item) {
+const active = exports.active = function(item) {
insert(item, false);
};
@@ -351,19 +351,19 @@ exports.setTimeout = function(callback, after) {
if (process.domain) timer.domain = process.domain;
- exports.active(timer);
+ active(timer);
return timer;
};
-exports.clearTimeout = function(timer) {
+const clearTimeout = exports.clearTimeout = function(timer) {
if (timer && (timer[kOnTimeout] || timer._onTimeout)) {
timer[kOnTimeout] = timer._onTimeout = null;
if (timer instanceof Timeout) {
timer.close(); // for after === 0
} else {
- exports.unenroll(timer);
+ unenroll(timer);
}
}
};
@@ -409,7 +409,7 @@ exports.setInterval = function(callback, repeat) {
timer._repeat = ontimeout;
if (process.domain) timer.domain = process.domain;
- exports.active(timer);
+ active(timer);
return timer;
@@ -425,7 +425,7 @@ exports.setInterval = function(callback, repeat) {
this._handle.start(repeat, 0);
} else {
timer._idleTimeout = repeat;
- exports.active(timer);
+ active(timer);
}
}
};
@@ -468,7 +468,7 @@ Timeout.prototype.unref = function() {
// Prevent running cb again when unref() is called during the same cb
if (this._called && !this._repeat) {
- exports.unenroll(this);
+ unenroll(this);
return;
}
@@ -496,7 +496,7 @@ Timeout.prototype.close = function() {
this._handle[kOnTimeout] = null;
this._handle.close();
} else {
- exports.unenroll(this);
+ unenroll(this);
}
return this;
};