From e0e2a99068b47824ec563eb24c2ee617499da491 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 23 Jan 2017 18:51:19 +0100 Subject: [PATCH] lib: cope with negative timeout in thread.c Since time is no longer cached, if we schedule something with zero timeout, it will automatically be negative by the time we reach the event loop. Signed-off-by: David Lamparter --- lib/thread.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/thread.c b/lib/thread.c index 406eddc9e6..de7066bb82 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -1203,6 +1203,12 @@ thread_fetch (struct thread_master *m, struct thread *fetch) timer_wait = timer_wait_bg; } + if (timer_wait && timer_wait->tv_sec < 0) + { + timerclear(&timer_val); + timer_wait = &timer_val; + } + num = fd_select (m, FD_SETSIZE, &readfd, &writefd, &exceptfd, timer_wait); /* Signals should get quick treatment */ -- 2.39.5