summaryrefslogtreecommitdiff
path: root/src/anet.c
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2022-05-02 07:37:14 +0100
committerGitHub <noreply@github.com>2022-05-02 09:37:14 +0300
commitef68deb3c2a4d6205ddc84141d4d84b6e53cbc1b (patch)
treea3db36e482c296b9142ce87550038b4d62def797 /src/anet.c
parent1666ffbe1f930c90b38584b79e547f7378549eca (diff)
downloadredis-ef68deb3c2a4d6205ddc84141d4d84b6e53cbc1b.tar.gz
support tcp-keepalive config interval on macOs (#10667)
Till now, on MacOS we only used to enable SO_KEEPALIVE, but we didn't set the interval which is configurable via the `tcp-keepalive` config. This adds support for that on MacOS, to match what we already do on Linux.
Diffstat (limited to 'src/anet.c')
-rw-r--r--src/anet.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/anet.c b/src/anet.c
index 3ded135b0..4ea201df5 100644
--- a/src/anet.c
+++ b/src/anet.c
@@ -162,6 +162,13 @@ int anetKeepAlive(char *err, int fd, int interval)
anetSetError(err, "setsockopt TCP_KEEPCNT: %s\n", strerror(errno));
return ANET_ERR;
}
+#elif defined(__APPLE__)
+ /* Set idle time with interval */
+ val = interval;
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) {
+ anetSetError(err, "setsockopt TCP_KEEPALIVE: %s\n", strerror(errno));
+ return ANET_ERR;
+ }
#else
((void) interval); /* Avoid unused var warning for non Linux systems. */
#endif