# HG changeset patch # User Aki Tuomi # Date 1474542823 -10800 # Node ID e5d797361253c668d48076285eb3eeea1106bcb8 # Parent efadeff4ab8d5783433f63656c9a036844ca2b36 lib: Update ioloop attributes With pending IO, the ioloop attributes still need updating, instead of just returning. diff -r efadeff4ab8d -r e5d797361253 src/lib/ioloop.c --- a/src/lib/ioloop.c Thu Sep 22 14:23:00 2016 +0300 +++ b/src/lib/ioloop.c Thu Sep 22 14:13:43 2016 +0300 @@ -393,13 +393,13 @@ struct timeout *timeout; int msecs; - /* if there are pending io, do not wait, possibly - forever, for them, but process them directly. */ - if (current_ioloop->io_pending_count > 0) return 0; - item = priorityq_peek(ioloop->timeouts); timeout = (struct timeout *)item; - if (timeout == NULL) { + + /* we need to see if there are pending IO waiting, + if there is, we set msecs = 0 to ensure they are + processed without delay */ + if (timeout == NULL && ioloop->io_pending_count == 0) { /* no timeouts. use INT_MAX msecs for timeval and return -1 for poll/epoll infinity. */ tv_r->tv_sec = INT_MAX / 1000; @@ -408,8 +408,14 @@ return -1; } - tv_now.tv_sec = 0; - msecs = timeout_get_wait_time(timeout, tv_r, &tv_now); + if (ioloop->io_pending_count > 0) { + if (gettimeofday(&tv_now, NULL) < 0) + i_fatal("gettimeofday(): %m"); + msecs = 0; + } else { + tv_now.tv_sec = 0; + msecs = timeout_get_wait_time(timeout, tv_r, &tv_now); + } ioloop->next_max_time = (tv_now.tv_sec + msecs/1000) + 1; /* update ioloop_timeval - this is meant for io_loop_handle_timeouts()'s