From 172f389395156d818e3da2b9f6adce41fd091739 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 21 Jan 2025 15:21:03 -0400 Subject: [PATCH] MT#55283 safeguard against Redis connect failure Avoids segfault is extra connection can't be established Closes #1903 Change-Id: I6eb7315f6774015703c7ad036e08596f7f550d60 --- daemon/redis.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/daemon/redis.c b/daemon/redis.c index 3fb9e5df0..4e18a812a 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2316,9 +2316,14 @@ int redis_restore(struct redis *r, bool foreign, int db) { mutex_init(&ctx.r_m); g_queue_init(&ctx.r_q); ctx.foreign = foreign; - for (int i = 0; i < rtpe_config.redis_num_threads; i++) - g_queue_push_tail(&ctx.r_q, - redis_dup(r, db)); + for (int i = 0; i < rtpe_config.redis_num_threads; i++) { + struct redis *dup = redis_dup(r, db); + if (!dup) { + rlog(LOG_ERR, "Failed to create thread connection to Redis"); + goto err; + } + g_queue_push_tail(&ctx.r_q, dup); + } gtp = g_thread_pool_new(restore_thread, &ctx, rtpe_config.redis_num_threads, TRUE, NULL); for (int i = 0; i < calls->elements; i++) {