dovecot-2.2: io_loop_run() now assert-crashes if it's attempted ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 23 14:35:12 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/c82ac3b0474f
changeset: 16868:c82ac3b0474f
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 23 14:35:07 2013 +0300
description:
io_loop_run() now assert-crashes if it's attempted to be used recursively for the same ioloop.

diffstat:

 src/lib/ioloop-private.h |  1 +
 src/lib/ioloop.c         |  6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r d06acaf2c640 -r c82ac3b0474f src/lib/ioloop-private.h
--- a/src/lib/ioloop-private.h	Wed Oct 23 14:34:35 2013 +0300
+++ b/src/lib/ioloop-private.h	Wed Oct 23 14:35:07 2013 +0300
@@ -25,6 +25,7 @@
 	time_t next_max_time;
 
 	unsigned int running:1;
+	unsigned int iolooping:1;
 };
 
 struct io {
diff -r d06acaf2c640 -r c82ac3b0474f src/lib/ioloop.c
--- a/src/lib/ioloop.c	Wed Oct 23 14:34:35 2013 +0300
+++ b/src/lib/ioloop.c	Wed Oct 23 14:35:07 2013 +0300
@@ -401,9 +401,15 @@
 	if (ioloop->cur_ctx != NULL)
 		io_loop_context_unref(&ioloop->cur_ctx);
 
+	/* recursive io_loop_run() isn't allowed for the same ioloop.
+	   it can break backends. */
+	i_assert(!ioloop->iolooping);
+	ioloop->iolooping = TRUE;
+
 	ioloop->running = TRUE;
 	while (ioloop->running)
 		io_loop_handler_run(ioloop);
+	ioloop->iolooping = FALSE;
 }
 
 void io_loop_stop(struct ioloop *ioloop)


More information about the dovecot-cvs mailing list