diff --git a/src/ev_epoll.c b/src/ev_epoll.c index 98ca701e1..746a0d120 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -222,8 +222,10 @@ static void _do_poll(struct poller *p, int exp, int wake) thread_idle_now(); thread_harmless_now(); - /* now let's wait for polled events */ - wait_time = wake ? 0 : compute_poll_timeout(exp); + /* Now let's wait for polled events. + * Check if the signal queue is not empty in case we received a signal + * before entering the loop, so we don't wait MAX_DELAY_MS for nothing */ + wait_time = (wake | signal_queue_len) ? 0 : compute_poll_timeout(exp); clock_entering_poll(); do { int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time; diff --git a/src/ev_evports.c b/src/ev_evports.c index 2530b39c0..7d3e8a8d7 100644 --- a/src/ev_evports.c +++ b/src/ev_evports.c @@ -178,10 +178,10 @@ static void _do_poll(struct poller *p, int exp, int wake) thread_idle_now(); thread_harmless_now(); - /* - * Determine how long to wait for events to materialise on the port. - */ - wait_time = wake ? 0 : compute_poll_timeout(exp); + /* Now let's wait for polled events. + * Check if the signal queue is not empty in case we received a signal + * before entering the loop, so we don't wait MAX_DELAY_MS for nothing */ + wait_time = (wake | signal_queue_len) ? 0 : compute_poll_timeout(exp); clock_entering_poll(); do { diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c index 3c8787ffd..1d6e91d50 100644 --- a/src/ev_kqueue.c +++ b/src/ev_kqueue.c @@ -166,8 +166,10 @@ static void _do_poll(struct poller *p, int exp, int wake) } fd_nbupdt = 0; - /* now let's wait for events */ - wait_time = wake ? 0 : compute_poll_timeout(exp); + /* Now let's wait for polled events. + * Check if the signal queue is not empty in case we received a signal + * before entering the loop, so we don't wait MAX_DELAY_MS for nothing */ + wait_time = (wake | signal_queue_len) ? 0 : compute_poll_timeout(exp); fd = global.tune.maxpollevents; clock_entering_poll(); diff --git a/src/ev_poll.c b/src/ev_poll.c index 790ea5bfa..6fefb3ab3 100644 --- a/src/ev_poll.c +++ b/src/ev_poll.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -203,8 +204,10 @@ static void _do_poll(struct poller *p, int exp, int wake) } } - /* now let's wait for events */ - wait_time = wake ? 0 : compute_poll_timeout(exp); + /* Now let's wait for polled events. + * Check if the signal queue is not empty in case we received a signal + * before entering the loop, so we don't wait MAX_DELAY_MS for nothing */ + wait_time = (wake | signal_queue_len) ? 0 : compute_poll_timeout(exp); clock_entering_poll(); status = poll(poll_events, nbfd, wait_time); clock_update_date(wait_time, status);