From 638e34bb81285f85c0d70ea01702adfe44715eff Mon Sep 17 00:00:00 2001 From: Kevin Binetruy Date: Tue, 13 Oct 2026 14:54:57 +0000 Subject: [PATCH] MT#55283 cli: reconnect only the Redis connections that exist Ref #2211 "set rediscmdtimeout 0" reconnects the Redis connections, but each of the three calls is guarded by rtpe_redis instead of its own pointer: - with --redis and no notification connection (no --redis-subscribe and no subscribed keyspace), redis_reconnect(rtpe_redis_notify) locks a NULL mutex and rtpengine crashes; - with --redis-write and no --redis, the write connection is never reconnected, so its command timeout is never cleared. Guard each call with its own pointer, as the non-zero branch already does. Tested by auto-daemon-tests-redis-errors.pl, added later in this series ("set rediscmdtimeout 0" over the ng "cli" command with --redis only): without this change rtpengine crashes and never replies. The change is first in the series so that it can be taken on its own. Change-Id: Ia458a6eb0b70a6906ab410fd91087ad5af581f3b (cherry picked from commit 20bcdce73c91d715a306ef2491c6f06682981634) (cherry picked from commit b789cab2c4a75e1833b7196a5ca8bb75d81ff0a6) --- daemon/cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/cli.c b/daemon/cli.c index 673782008..9c22ecc1e 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -1721,11 +1721,11 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct cli_writer *cw, cw->cw_printf(cw, "Failed reconnecting to redis\n"); fail = 1; } - if (rtpe_redis && redis_reconnect(rtpe_redis_write)) { + if (rtpe_redis_write && redis_reconnect(rtpe_redis_write)) { cw->cw_printf(cw, "Failed reconnecting to redis-write\n"); fail = 1; } - if (rtpe_redis && redis_reconnect(rtpe_redis_notify)) { + if (rtpe_redis_notify && redis_reconnect(rtpe_redis_notify)) { cw->cw_printf(cw, "Failed reconnecting to redis-notify\n"); fail = 1; }