summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-02-16 12:13:21 -0800
committerdormando <dormando@rydia.net>2022-02-16 12:13:21 -0800
commitc985f2bb8f90e7f36db5d4007c5cf3999bacf6ba (patch)
treef92ef8e7cfcce6409467052e1588f052d3294216 /vendor
parent7e58c6dd333b03e2cd7f1b1ef286da39f1a67fc3 (diff)
downloadmemcached-c985f2bb8f90e7f36db5d4007c5cf3999bacf6ba.tar.gz
mcmc: upstream update for SO_KEEPALIVE
Diffstat (limited to 'vendor')
-rw-r--r--vendor/mcmc/mcmc.c10
-rw-r--r--vendor/mcmc/mcmc.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/vendor/mcmc/mcmc.c b/vendor/mcmc/mcmc.c
index 65b7e68..e62cdea 100644
--- a/vendor/mcmc/mcmc.c
+++ b/vendor/mcmc/mcmc.c
@@ -454,7 +454,15 @@ int mcmc_connect(void *c, char *host, char *port, int options) {
if (sock == -1)
continue;
- // TODO: NONBLOCK
+ if (options & MCMC_OPTION_TCP_KEEPALIVE) {
+ int optval = 1;
+ if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) {
+ res = MCMC_ERR;
+ close(sock);
+ goto end;
+ }
+ }
+
if (options & MCMC_OPTION_NONBLOCK) {
int flags = fcntl(sock, F_GETFL);
if (flags < 0) {
diff --git a/vendor/mcmc/mcmc.h b/vendor/mcmc/mcmc.h
index 1769228..dba159a 100644
--- a/vendor/mcmc/mcmc.h
+++ b/vendor/mcmc/mcmc.h
@@ -37,6 +37,7 @@
#define MCMC_OPTION_BLANK 0
#define MCMC_OPTION_NONBLOCK 1
+#define MCMC_OPTION_TCP_KEEPALIVE (1<<1)
// convenience defines. if you want to save RAM you can set these smaller and
// error handler will only copy what you ask for.