LibCore: CEventLoop: If timeval_sub makes tv_sec negative, use 0

This commit is contained in:
joshua stein 2020-02-02 01:10:37 -06:00 committed by Andreas Kling
parent 0c4c5b5eb7
commit dac07a5d76
Notes: sideshowbarker 2024-07-19 09:36:45 +09:00

View File

@ -371,6 +371,10 @@ void EventLoop::wait_for_event(WaitMode mode)
gettimeofday(&now, nullptr);
get_next_timer_expiration(timeout);
timeval_sub(timeout, now, timeout);
if (timeout.tv_sec < 0) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
} else {
should_wait_forever = true;
}