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
pull/2217/head
Kevin Binetruy 1 month ago committed by Richard Fuchs
parent 046f7e2c71
commit 20bcdce73c

@ -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;
}

Loading…
Cancel
Save