From a6e2d5113fb98d02432defad7acbeed89bbb8228 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 11 Dec 2014 15:19:23 +0100 Subject: [PATCH] In redisIsSupervised() use MSG_NOSIGNAL only for Linux. --- src/config.h | 5 +++++ src/redis.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index 1f2919ed2..2b5004baa 100644 --- a/src/config.h +++ b/src/config.h @@ -61,6 +61,11 @@ #define HAVE_BACKTRACE 1 #endif +/* MSG_NOSIGNAL. */ +#ifdef __linux__ +#define HAVE_MSG_NOSIGNAL 1 +#endif + /* Test for polling API */ #ifdef __linux__ #define HAVE_EPOLL 1 diff --git a/src/redis.c b/src/redis.c index 45140139c..030cfbb48 100644 --- a/src/redis.c +++ b/src/redis.c @@ -3586,6 +3586,7 @@ int redisIsSupervised(void) { struct sockaddr_un su; struct iovec iov; struct msghdr hdr; + int sendto_flags = 0; if (upstart_job == NULL && notify_socket == NULL) return 0; @@ -3631,8 +3632,11 @@ int redisIsSupervised(void) { hdr.msg_iovlen = 1; unsetenv("NOTIFY_SOCKET"); - if (sendmsg(fd, &hdr, MSG_NOSIGNAL) < 0) { - redisLog(REDIS_WARNING, "cannot send notification to systemd"); +#ifdef HAVE_MSG_NOSIGNAL + sendto_flags |= MSG_NOSIGNAL; +#endif + if (sendmsg(fd, &hdr, sendto_flags) < 0) { + redisLog(REDIS_WARNING, "Cannot send notification to systemd"); close(fd); return 0; }