mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-30 10:06:43 +00:00
BUG/MINOR: signals: ha_sigmask macro for multithreading
The behavior of sigprocmask in an multithreaded environment is undefined. The new macro ha_sigmask() calls either pthreads_sigmask() or sigprocmask() if haproxy was built with thread support or not. This should be backported to 1.8.
This commit is contained in:
parent
933642c6ef
commit
6e1796e85d
@ -108,6 +108,9 @@ extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the threa
|
||||
#define HA_RWLOCK_TRYRDLOCK(lbl, l) ({ 0; })
|
||||
#define HA_RWLOCK_RDUNLOCK(lbl, l) do { /* do nothing */ } while(0)
|
||||
|
||||
#define ha_sigmask(how, set, oldset) sigprocmask(how, set, oldset)
|
||||
|
||||
|
||||
static inline void __ha_barrier_load(void)
|
||||
{
|
||||
}
|
||||
@ -259,6 +262,9 @@ int thread_need_sync(void);
|
||||
|
||||
extern unsigned long all_threads_mask;
|
||||
|
||||
#define ha_sigmask(how, set, oldset) pthread_sigmask(how, set, oldset)
|
||||
|
||||
|
||||
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
|
||||
|
||||
/* WARNING!!! if you update this enum, please also keep lock_label() up to date below */
|
||||
|
@ -1618,7 +1618,7 @@ void block_sigchld(void)
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGCHLD);
|
||||
assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0);
|
||||
assert(ha_sigmask(SIG_BLOCK, &set, NULL) == 0);
|
||||
}
|
||||
|
||||
void unblock_sigchld(void)
|
||||
@ -1626,7 +1626,7 @@ void unblock_sigchld(void)
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGCHLD);
|
||||
assert(sigprocmask(SIG_UNBLOCK, &set, NULL) == 0);
|
||||
assert(ha_sigmask(SIG_UNBLOCK, &set, NULL) == 0);
|
||||
}
|
||||
|
||||
static struct pid_list *pid_list_add(pid_t pid, struct task *t)
|
||||
|
@ -508,7 +508,7 @@ static void mworker_block_signals()
|
||||
sigaddset(&set, SIGHUP);
|
||||
sigaddset(&set, SIGINT);
|
||||
sigaddset(&set, SIGTERM);
|
||||
sigprocmask(SIG_SETMASK, &set, NULL);
|
||||
ha_sigmask(SIG_SETMASK, &set, NULL);
|
||||
}
|
||||
|
||||
static void mworker_unblock_signals()
|
||||
@ -521,7 +521,7 @@ static void mworker_unblock_signals()
|
||||
sigaddset(&set, SIGHUP);
|
||||
sigaddset(&set, SIGINT);
|
||||
sigaddset(&set, SIGTERM);
|
||||
sigprocmask(SIG_UNBLOCK, &set, NULL);
|
||||
ha_sigmask(SIG_UNBLOCK, &set, NULL);
|
||||
}
|
||||
|
||||
static void mworker_unregister_signals()
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <common/hathreads.h>
|
||||
|
||||
#include <proto/signal.h>
|
||||
#include <proto/log.h>
|
||||
#include <proto/task.h>
|
||||
@ -71,7 +73,7 @@ void __signal_process_queue()
|
||||
sigset_t old_sig;
|
||||
|
||||
/* block signal delivery during processing */
|
||||
sigprocmask(SIG_SETMASK, &blocked_sig, &old_sig);
|
||||
ha_sigmask(SIG_SETMASK, &blocked_sig, &old_sig);
|
||||
|
||||
/* It is important that we scan the queue forwards so that we can
|
||||
* catch any signal that would have been queued by another signal
|
||||
@ -95,7 +97,7 @@ void __signal_process_queue()
|
||||
signal_queue_len = 0;
|
||||
|
||||
/* restore signal delivery */
|
||||
sigprocmask(SIG_SETMASK, &old_sig, NULL);
|
||||
ha_sigmask(SIG_SETMASK, &old_sig, NULL);
|
||||
}
|
||||
|
||||
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
|
||||
@ -116,7 +118,7 @@ int signal_init()
|
||||
* parsing We don't want the process to be killed by an unregistered
|
||||
* USR2 signal when the master-worker is reloading */
|
||||
sigaddset(&blocked_sig, SIGUSR2);
|
||||
sigprocmask(SIG_SETMASK, &blocked_sig, NULL);
|
||||
ha_sigmask(SIG_SETMASK, &blocked_sig, NULL);
|
||||
|
||||
sigfillset(&blocked_sig);
|
||||
sigdelset(&blocked_sig, SIGPROF);
|
||||
|
Loading…
Reference in New Issue
Block a user