nbd-server: block SIGCHLD when handling SIGTERM, and visa versa
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Jun 2012 21:45:01 +0000 (01:45 +0400)
committerWouter Verhelst <w@uter.be>
Sat, 23 Jun 2012 23:38:35 +0000 (01:38 +0200)
SIGCHLD handler must be blocked during execution of SIGTERM handler,
and visa versa, because the former changes "children" hash table
iterated by the latter.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
nbd-server.c

index 0868447f9ed717dc603df65c8a45a7e9a54ed890..80681c7e3a90867677ed5409d84bd1bd22deba0f 100644 (file)
@@ -2454,11 +2454,14 @@ void setup_servers(GArray* servers) {
 
        sa.sa_handler = sigchld_handler;
        sigemptyset(&sa.sa_mask);
+       sigaddset(&sa.sa_mask, SIGTERM);
        sa.sa_flags = SA_RESTART;
        if(sigaction(SIGCHLD, &sa, NULL) == -1)
                err("sigaction: %m");
+
        sa.sa_handler = sigterm_handler;
        sigemptyset(&sa.sa_mask);
+       sigaddset(&sa.sa_mask, SIGCHLD);
        sa.sa_flags = SA_RESTART;
        if(sigaction(SIGTERM, &sa, NULL) == -1)
                err("sigaction: %m");