From 3b3fceacbe3dd1f0ed0a1ddc3b529e62f92ef146 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Jan 2008 09:43:14 +1100 Subject: [PATCH] block alarm signals during critical sections of vacuum (This used to be ctdb commit cfb14ae76f00f10d27b56c034b2247ab12d63065) --- ctdb/common/ctdb_util.c | 19 +++++++++++++++++++ ctdb/include/ctdb_private.h | 2 ++ ctdb/server/ctdbd.c | 14 +------------- ctdb/tools/ctdb_vacuum.c | 2 ++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index 90489a7a716..7f7c1a0c8a6 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -22,6 +22,7 @@ #include "lib/tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" +#include "system/wait.h" #include "../include/ctdb_private.h" int LogLevel; @@ -340,3 +341,21 @@ bool ctdb_same_sockaddr(const struct sockaddr_in *ip1, const struct sockaddr_in { return ctdb_same_ip(ip1, ip2) && ip1->sin_port == ip2->sin_port; } + + + +void ctdb_block_signal(int signum) +{ + sigset_t set; + sigemptyset(&set); + sigaddset(&set,signum); + sigprocmask(SIG_BLOCK,&set,NULL); +} + +void ctdb_unblock_signal(int signum) +{ + sigset_t set; + sigemptyset(&set); + sigaddset(&set,signum); + sigprocmask(SIG_UNBLOCK,&set,NULL); +} diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index f59ffeeed0d..a876100d41f 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1209,5 +1209,7 @@ int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv); int32_t ctdb_control_delete_record(struct ctdb_context *ctdb, TDB_DATA indata); +void ctdb_block_signal(int signum); +void ctdb_unblock_signal(int signum); #endif diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 5613ea91b7d..a386cea8aee 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -26,18 +26,6 @@ #include "cmdline.h" #include "../include/ctdb_private.h" -static void block_signal(int signum) -{ - struct sigaction act; - - memset(&act, 0, sizeof(act)); - - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask, signum); - sigaction(signum, &act, NULL); -} - static struct { const char *nlist; const char *transport; @@ -149,7 +137,7 @@ int main(int argc, const char *argv[]) exit(1); } - block_signal(SIGPIPE); + ctdb_block_signal(SIGPIPE); ev = event_context_init(NULL); diff --git a/ctdb/tools/ctdb_vacuum.c b/ctdb/tools/ctdb_vacuum.c index 86d9c4c5f19..c3a69f7fa8f 100644 --- a/ctdb/tools/ctdb_vacuum.c +++ b/ctdb/tools/ctdb_vacuum.c @@ -208,7 +208,9 @@ static int ctdb_vacuum_one(struct ctdb_context *ctdb, TDB_DATA key, return 0; } + ctdb_block_signal(SIGALRM); tdb_delete(ctdb_db->ltdb->tdb, key); + ctdb_unblock_signal(SIGALRM); tdb_chainunlock(ctdb_db->ltdb->tdb, key); free(data.dptr);