Skip to content

Commit

Permalink
Manipulate the delay only when it is positive
Browse files Browse the repository at this point in the history
The return value of '_twin_timeout_delay' might be negative, and the
polling should be aware of it; otherwise, an unbounded delay occurs.
  • Loading branch information
jserv committed Dec 5, 2024
1 parent 16f7f9e commit a90b142
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ void twin_dispatch(twin_context_t *ctx)
_twin_run_timeout();
_twin_run_work();
if (g_twin_backend.poll && !g_twin_backend.poll(ctx)) {
usleep(_twin_timeout_delay() * 1000);
twin_time_t delay = _twin_timeout_delay();
if (delay > 0)
usleep(delay * 1000);
break;
}
}
Expand Down

0 comments on commit a90b142

Please sign in to comment.