Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
process: remove maxTickDepth from _tickCallback
Browse files Browse the repository at this point in the history
Removes the check for maxTickDepth for non-domain callbacks. So a user
can starve I/O by setting a recursive nextTick.

The domain case is more complex and will be addressed in another commit.
  • Loading branch information
trevnorris committed May 30, 2013
1 parent 5b636fe commit 0761c90
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 138 deletions.
1 change: 0 additions & 1 deletion src/node.cc
Expand Up @@ -1029,7 +1029,6 @@ MakeCallback(const Handle<Object> object,

if (tick_infobox.length == 0) {
tick_infobox.index = 0;
tick_infobox.depth = 0;
return ret;
}

Expand Down
25 changes: 8 additions & 17 deletions src/node.js
Expand Up @@ -398,25 +398,18 @@
if (inTick) return;
if (infoBox[length] === 0) {
infoBox[index] = 0;
infoBox[depth] = 0;
return;
}
inTick = true;

while (infoBox[depth]++ < process.maxTickDepth) {
nextTickLength = infoBox[length];
if (infoBox[index] === nextTickLength)
return tickDone(0);

while (infoBox[index] < nextTickLength) {
callback = nextTickQueue[infoBox[index]++].callback;
threw = true;
try {
callback();
threw = false;
} finally {
if (threw) tickDone(infoBox[depth]);
}
while (infoBox[index] < infoBox[length]) {
callback = nextTickQueue[infoBox[index]++].callback;
threw = true;
try {
callback();
threw = false;
} finally {
if (threw) tickDone(0);
}
}

Expand Down Expand Up @@ -476,8 +469,6 @@
// on the way out, don't bother. it won't get fired anyway.
if (process._exiting)
return;
if (infoBox[depth] >= process.maxTickDepth)
maxTickWarn();

var obj = { callback: callback, domain: null };

Expand Down
2 changes: 0 additions & 2 deletions test/message/max_tick_depth.out
Expand Up @@ -8,7 +8,6 @@ tick 14
tick 13
tick 12
tick 11
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 10
tick 9
tick 8
Expand All @@ -19,5 +18,4 @@ tick 4
tick 3
tick 2
tick 1
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
tick 0
31 changes: 0 additions & 31 deletions test/message/max_tick_depth_trace.js

This file was deleted.

35 changes: 0 additions & 35 deletions test/message/max_tick_depth_trace.out

This file was deleted.

52 changes: 0 additions & 52 deletions test/simple/test-next-tick-starvation.js

This file was deleted.

0 comments on commit 0761c90

Please sign in to comment.