summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyan Graham <r.m.graham@gmail.com>2014-01-08 21:19:31 -0800
committerTrevor Norris <trev.norris@gmail.com>2014-01-15 12:27:10 -0800
commit7f81ca2c47a7c9376f831e8be5d62a5adc917e4e (patch)
tree2426dae7c5d6e0bab3a502572b0a8e0175cc2328 /lib
parente7f7e2aeca77485b99969dccedb4b71e2c157b9d (diff)
downloadandroid-node-v8-7f81ca2c47a7c9376f831e8be5d62a5adc917e4e.tar.gz
android-node-v8-7f81ca2c47a7c9376f831e8be5d62a5adc917e4e.tar.bz2
android-node-v8-7f81ca2c47a7c9376f831e8be5d62a5adc917e4e.zip
domains: exit() only affects active domains
domain.create().exit() should not clear the domain stack if the domain instance does not exist within the stack. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/domain.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/domain.js b/lib/domain.js
index 80a64c64bf..afaa922ebe 100644
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -67,13 +67,13 @@ Domain.prototype.enter = function() {
};
Domain.prototype.exit = function() {
- if (this._disposed) return;
+ // skip disposed domains, as usual, but also don't do anything if this
+ // domain is not on the stack.
+ var index = stack.lastIndexOf(this);
+ if (this._disposed || index === -1) return;
// exit all domains until this one.
- var d;
- do {
- d = stack.pop();
- } while (d && d !== this);
+ stack.splice(index);
exports.active = stack[stack.length - 1];
process.domain = exports.active;