Skip to content

Commit b50fea4

Browse files
saghulrvagg
authored andcommitted
watchdog: fix timeout for early polling return
Switch from running the loop with UV_RUN_ONCE to UV_RUN_DEFAULT, because it's possible that the poll returns earlier than expected and thus the timer is not run on a single interation. The loop is not stopped either from the timer callback or from the async handle's. PR-URL: #622 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent b5166cb commit b50fea4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/node_watchdog.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ void Watchdog::Destroy() {
6565
void Watchdog::Run(void* arg) {
6666
Watchdog* wd = static_cast<Watchdog*>(arg);
6767

68-
// UV_RUN_ONCE so async_ or timer_ wakeup exits uv_run() call.
69-
uv_run(wd->loop_, UV_RUN_ONCE);
68+
// UV_RUN_DEFAULT the loop will be stopped either by the async or the
69+
// timer handle.
70+
uv_run(wd->loop_, UV_RUN_DEFAULT);
7071

7172
// Loop ref count reaches zero when both handles are closed.
7273
// Close the timer handle on this side and let Destroy() close async_
@@ -75,11 +76,14 @@ void Watchdog::Run(void* arg) {
7576

7677

7778
void Watchdog::Async(uv_async_t* async) {
79+
Watchdog* w = ContainerOf(&Watchdog::async_, async);
80+
uv_stop(w->loop_);
7881
}
7982

8083

8184
void Watchdog::Timer(uv_timer_t* timer) {
8285
Watchdog* w = ContainerOf(&Watchdog::timer_, timer);
86+
uv_stop(w->loop_);
8387
V8::TerminateExecution(w->env()->isolate());
8488
}
8589

0 commit comments

Comments
 (0)