From 1e842aaf14083cb0cefd809093e85f1c48173b99 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 9 Apr 2020 15:55:59 +0300 Subject: [PATCH] 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. --- src/lib/ioloop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.47.3