if (!clients_connected)
sched.reset();
- wait_ms = 0;
+ wait_ms = -1;
if (sched.isRunning()) {
wait_ms = sched.millisRemaining();
// Trigger timers and check when the next will expire
nextTimeout = Timer::checkTimeouts();
- if (nextTimeout >= 0 && nextTimeout < wait_ms)
+ if (nextTimeout >= 0 && (wait_ms == -1 || nextTimeout < wait_ms))
wait_ms = nextTimeout;
tv.tv_sec = wait_ms / 1000;
// Do the wait...
sched.sleepStarted();
int n = select(FD_SETSIZE, &rfds, &wfds, 0,
- wait_ms ? &tv : NULL);
+ wait_ms >= 0 ? &tv : NULL);
sched.sleepFinished();
if (n < 0) {