summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Brail <greg@apigee.com>2014-01-28 17:36:22 -0800
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-03-03 17:46:49 -0800
commit6eb4d1d15ca8d2b82cf9db99d56633357ccc3320 (patch)
treedb84aef134c16e36cffdfa1e60a0ef57f96d95cf /lib
parent06453a94a7b06df30be0148e8b1d89932350f677 (diff)
downloadandroid-node-v8-6eb4d1d15ca8d2b82cf9db99d56633357ccc3320.tar.gz
android-node-v8-6eb4d1d15ca8d2b82cf9db99d56633357ccc3320.tar.bz2
android-node-v8-6eb4d1d15ca8d2b82cf9db99d56633357ccc3320.zip
timer: don't reschedule timer bucket in a domain
If two timers run on the same tick, and the first timer uses a domain, and then catches an exception and disposes of the domain, then the second timer never runs. (And even if the first timer does not dispose of the domain, the second timer could run under the wrong domain.) This happens because timer.js uses "process.nextTick()" to schedule continued processing of the timers for that tick. However, there was an exception inside a domain, then "process.nextTick()" runs under the domain of the first timer function, and will do nothing if the domain has been disposed. To avoid this, we temporarily save the value of "process.domain" before calling nextTick so that it does not run inside any domain.
Diffstat (limited to 'lib')
-rw-r--r--lib/timers.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/timers.js b/lib/timers.js
index 076503e601..db4f5bd972 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -113,9 +113,15 @@ function listOnTimeout() {
threw = false;
} finally {
if (threw) {
+ // We need to continue processing after domain error handling
+ // is complete, but not by using whatever domain was left over
+ // when the timeout threw its exception.
+ var oldDomain = process.domain;
+ process.domain = null;
process.nextTick(function() {
list.ontimeout();
});
+ process.domain = oldDomain;
}
}
}