mirror of https://github.com/nodejs/node.git
node: invoke `beforeExit` again if loop was active
When `setImmediate(cb)` is called in `beforeExit` event handler the consequent `uv_run(..., UV_RUN_NOWAIT)` may return `0`, even if there was some active handles at start. Fixes simple/test-beforeexit-event.js.pull/28770/head
parent
3b88dc6f19
commit
5596f936d8
|
@ -3536,7 +3536,12 @@ int Start(int argc, char** argv) {
|
||||||
more = uv_run(env->event_loop(), UV_RUN_ONCE);
|
more = uv_run(env->event_loop(), UV_RUN_ONCE);
|
||||||
if (more == false) {
|
if (more == false) {
|
||||||
EmitBeforeExit(env);
|
EmitBeforeExit(env);
|
||||||
more = uv_run(env->event_loop(), UV_RUN_NOWAIT);
|
|
||||||
|
// Emit `beforeExit` if the loop became alive either after emitting
|
||||||
|
// event, or after running some callbacks.
|
||||||
|
more = uv_loop_alive(env->event_loop());
|
||||||
|
if (uv_run(env->event_loop(), UV_RUN_NOWAIT) != 0)
|
||||||
|
more = true;
|
||||||
}
|
}
|
||||||
} while (more == true);
|
} while (more == true);
|
||||||
code = EmitExit(env);
|
code = EmitExit(env);
|
||||||
|
|
Loading…
Reference in New Issue