changeset 20754:117d25f8c9c4

lib: Prevent crash in ioloop If only non-fd sources and no timeouts are in ioloop, prevent crash and unnecessary waiting when there are pending IOs.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Fri, 16 Sep 2016 15:49:36 +0300
parents 5e25d263dcf0
children 4be088d2993b
files src/lib/ioloop.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/ioloop.c	Mon Sep 19 16:20:14 2016 +0300
+++ b/src/lib/ioloop.c	Fri Sep 16 15:49:36 2016 +0300
@@ -393,6 +393,10 @@
 	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) {