summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net.c1
-rw-r--r--test.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/net.c b/net.c
index 3968acc..1e01638 100644
--- a/net.c
+++ b/net.c
@@ -234,6 +234,7 @@ int redisContextSetTcpUserTimeout(redisContext *c, unsigned int timeout) {
res = setsockopt(c->fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, sizeof(timeout));
#else
res = -1;
+ errno = ENOTSUP;
(void)timeout;
#endif
if (res == -1) {
diff --git a/test.c b/test.c
index a9afe90..e3d808d 100644
--- a/test.c
+++ b/test.c
@@ -409,10 +409,19 @@ static void test_tcp_options(struct config cfg) {
redisContext *c;
c = do_connect(cfg);
+
test("We can enable TCP_KEEPALIVE: ");
test_cond(redisEnableKeepAlive(c) == REDIS_OK);
- disconnect(c, 0);
+#ifdef TCP_USER_TIMEOUT
+ test("We can set TCP_USER_TIMEOUT: ");
+ test_cond(redisSetTcpUserTimeout(c, 100) == REDIS_OK);
+#else
+ test("Setting TCP_USER_TIMEOUT errors when unsupported: ");
+ test_cond(redisSetTcpUserTimeout(c, 100) == REDIS_ERR && c->err == REDIS_ERR_IO);
+#endif
+
+ redisFree(c);
}
static void test_reply_reader(void) {