Skip to content

Commit 67e4d3e

Browse files
committed
cachedb_redis: guard redisEnableKeepAliveWithInterval for hiredis < 1.0
redisEnableKeepAliveWithInterval() was added in hiredis 1.0.0. Ubuntu 20.04 ships hiredis 0.14, causing an implicit-function-declaration error with -Werror. Gate on HIREDIS_MAJOR >= 1, falling back to redisEnableKeepAlive() (no interval parameter) on older versions.
1 parent 58741ce commit 67e4d3e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

modules/cachedb_redis/cachedb_redis_dbase.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ redisContext *redis_get_ctx(char *ip, int port)
9898
}
9999

100100
if (redis_keepalive > 0) {
101+
#if defined(HIREDIS_MAJOR) && HIREDIS_MAJOR >= 1
101102
if (redisEnableKeepAliveWithInterval(ctx, redis_keepalive) != REDIS_OK)
103+
#else
104+
if (redisEnableKeepAlive(ctx) != REDIS_OK)
105+
#endif
102106
LM_WARN("failed to enable TCP keepalive on redis connection "
103107
"%s:%hu\n", ip, (unsigned short)port);
104108
}

0 commit comments

Comments
 (0)