From: Timo Sirainen Date: Wed, 23 Oct 2013 11:35:07 +0000 (+0300) Subject: io_loop_run() now assert-crashes if it's attempted to be used recursively for the... X-Git-Tag: 2.2.7~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ecc0cf8395c1e4036ce483ff4bf08855312074e9;p=thirdparty%2Fdovecot%2Fcore.git io_loop_run() now assert-crashes if it's attempted to be used recursively for the same ioloop. --- diff --git a/src/lib/ioloop-private.h b/src/lib/ioloop-private.h index e24202b11b..afbe39d6ae 100644 --- a/src/lib/ioloop-private.h +++ b/src/lib/ioloop-private.h @@ -25,6 +25,7 @@ struct ioloop { time_t next_max_time; unsigned int running:1; + unsigned int iolooping:1; }; struct io { diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index 179507cc72..8d1b429968 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -401,9 +401,15 @@ void io_loop_run(struct ioloop *ioloop) 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)