summaryrefslogtreecommitdiff
path: root/src/bio.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-03-27 13:48:53 +0200
committerantirez <antirez@gmail.com>2012-03-27 13:48:57 +0200
commitaa96122d968308f77c4d26ba24c6ec9727b4e88b (patch)
tree96527c7cc66b5e8c0c820b021a1bb090602b5d7c /src/bio.c
parenta354da9acd8afbe4e600360ef6502c10dfed3ccb (diff)
downloadredis-aa96122d968308f77c4d26ba24c6ec9727b4e88b.tar.gz
Mask SIGALRM everything but in the main thread.
This is required to ensure that the signal will be delivered to the main thread when the watchdog timer expires.
Diffstat (limited to 'src/bio.c')
-rw-r--r--src/bio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bio.c b/src/bio.c
index eaac8e40d..aa2cdf9fb 100644
--- a/src/bio.c
+++ b/src/bio.c
@@ -108,9 +108,18 @@ void bioCreateBackgroundJob(int type, void *arg1, void *arg2, void *arg3) {
void *bioProcessBackgroundJobs(void *arg) {
struct bio_job *job;
unsigned long type = (unsigned long) arg;
+ sigset_t sigset;
pthread_detach(pthread_self());
pthread_mutex_lock(&bio_mutex[type]);
+ /* Block SIGALRM so we are sure that only the main thread will
+ * receive the watchdog signal. */
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGALRM);
+ if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
+ redisLog(REDIS_WARNING,
+ "Warning: can't mask SIGALRM in bio.c thread: %s", strerror(errno));
+
while(1) {
listNode *ln;