dovecot-2.2: ioloop-epoll: Allow running ioloop even without any...

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 8 23:40:48 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/587c5579c598
changeset: 14747:587c5579c598
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 08 23:40:37 2012 +0300
description:
ioloop-epoll: Allow running ioloop even without any I/Os (only timeouts).

diffstat:

 src/lib/ioloop-epoll.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (23 lines):

diff -r 6de60c6ea713 -r 587c5579c598 src/lib/ioloop-epoll.c
--- a/src/lib/ioloop-epoll.c	Wed Aug 08 01:13:10 2012 +0300
+++ b/src/lib/ioloop-epoll.c	Wed Aug 08 23:40:37 2012 +0300
@@ -178,9 +178,16 @@
 	msecs = io_loop_get_wait_time(ioloop, &tv);
 
 	events = array_get_modifiable(&ctx->events, &events_count);
-	ret = epoll_wait(ctx->epfd, events, events_count, msecs);
-	if (ret < 0 && errno != EINTR)
-		i_fatal("epoll_wait(): %m");
+	if (events_count > 0) {
+		ret = epoll_wait(ctx->epfd, events, events_count, msecs);
+		if (ret < 0 && errno != EINTR)
+			i_fatal("epoll_wait(): %m");
+	} else {
+		/* no I/Os, but we should have some timeouts.
+		   just wait for them. */
+		if (msecs > 0)
+			usleep(msecs*1000);
+	}
 
 	/* execute timeout handlers */
         io_loop_handle_timeouts(ioloop);


More information about the dovecot-cvs mailing list