From 2575407ffec5a43ac55eba370a00243d368bcb8d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 12 Sep 2020 07:43:56 -0700 Subject: [PATCH] helper_thread: Introduce a function for blocking Unix signals This patch reworks commit c31092b8ac06 ("Block signals for the helper thread") but does not change any functionality. Signed-off-by: Bart Van Assche --- helper_thread.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/helper_thread.c b/helper_thread.c index c5ca23e0..88937ade 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -83,6 +83,18 @@ static int read_from_pipe(int fd, void *buf, size_t len) } #endif +static void block_signals(void) +{ +#ifdef HAVE_PTHREAD_SIGMASK + sigset_t sigmask; + + ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask); + assert(ret == 0); + ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL); + assert(ret == 0); +#endif +} + static void submit_action(enum action a) { const char data = a; @@ -157,17 +169,8 @@ static void *helper_thread_main(void *data) sk_out_assign(hd->sk_out); -#ifdef HAVE_PTHREAD_SIGMASK - { - sigset_t sigmask; - /* Let another thread handle signals. */ - ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask); - assert(ret == 0); - ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL); - assert(ret == 0); - } -#endif + block_signals(); fio_get_mono_time(&ts); memcpy(&last_du, &ts, sizeof(ts)); -- 2.25.1