Skip to content

Commit a90b142

Browse files
committed
Manipulate the delay only when it is positive
The return value of '_twin_timeout_delay' might be negative, and the polling should be aware of it; otherwise, an unbounded delay occurs.
1 parent 16f7f9e commit a90b142

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/dispatch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ void twin_dispatch(twin_context_t *ctx)
1717
_twin_run_timeout();
1818
_twin_run_work();
1919
if (g_twin_backend.poll && !g_twin_backend.poll(ctx)) {
20-
usleep(_twin_timeout_delay() * 1000);
20+
twin_time_t delay = _twin_timeout_delay();
21+
if (delay > 0)
22+
usleep(delay * 1000);
2123
break;
2224
}
2325
}

0 commit comments

Comments
 (0)