From 81490f410366db2f76558ee31de27674cb1375a3 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Tue, 1 May 2012 11:21:50 +0400 Subject: [PATCH] Make sure the WAL writer thread doesn't handle any signals. --- include/tarantool_pthread.h | 12 ++++++++++++ src/log_io.m | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/tarantool_pthread.h b/include/tarantool_pthread.h index 41094a031a..70d847c2b1 100644 --- a/include/tarantool_pthread.h +++ b/include/tarantool_pthread.h @@ -154,5 +154,17 @@ tt_pthread_error(e); \ }) +/** Make sure the created thread blocks all signals, + * they are handled in the main thread. + */ +#define tt_pthread_create(thread, attr, run, arg) \ +({ sigset_t set, oldset; \ + sigfillset(&set); \ + pthread_sigmask(SIG_BLOCK, &set, &oldset); \ + int e = pthread_create(thread, attr, run, arg); \ + pthread_sigmask(SIG_SETMASK, &oldset, NULL); \ + tt_pthread_error(e); \ +}) + #endif /* TARANTOOL_PTHREAD_H_INCLUDED */ diff --git a/src/log_io.m b/src/log_io.m index 684842164a..cb63106447 100644 --- a/src/log_io.m +++ b/src/log_io.m @@ -1357,8 +1357,8 @@ wal_writer_start(struct recovery_state *state) /* II. Start the thread. */ - if (pthread_create(&wal_writer.thread, NULL, wal_writer_thread, - state)) { + if (tt_pthread_create(&wal_writer.thread, NULL, wal_writer_thread, + state)) { wal_writer_destroy(&wal_writer); state->writer = NULL; return -1; -- GitLab