From: Timo Sirainen Date: Thu, 9 Apr 2020 12:55:59 +0000 (+0300) Subject: lib: Reverse comment about io_loop_stop() being safe to call in signal handlers X-Git-Tag: 2.3.13~731 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e842aaf14083cb0cefd809093e85f1c48173b99;p=thirdparty%2Fdovecot%2Fcore.git lib: Reverse comment about io_loop_stop() being safe to call in signal handlers It is not safe. First there's the issue that ioloop.running is a bitmask, but secondly there's a race condition between io_loop_stop() and the arrival of the last timeout and/or IO event. It can end up running epoll_wait() with only a stale IO and no timeouts, which hangs indefinitely. --- diff --git a/src/lib/ioloop.h b/src/lib/ioloop.h index c51296512f..c48a5b5e13 100644 --- a/src/lib/ioloop.h +++ b/src/lib/ioloop.h @@ -182,7 +182,7 @@ void io_loop_time_refresh(void); void io_loop_run(struct ioloop *ioloop); /* Stop the ioloop immediately. No further IO or timeout callbacks are called. - This is safe to run in a signal handler. */ + Warning: This is not safe to be called in non-delayed signal handlers. */ void io_loop_stop(struct ioloop *ioloop); /* Stop ioloop after finishing all the pending IOs and timeouts. */ void io_loop_stop_delayed(struct ioloop *ioloop);