From 50aef804d92648dc8b3b19b569dc63a014f8205a Mon Sep 17 00:00:00 2001 From: smititelu Date: Mon, 15 Feb 2016 13:02:27 +0100 Subject: [PATCH] Rtpengine starts even if redis is down Rtpengine will start with a warning message if redis is configured, but is not up and running. --- daemon/redis.c | 21 +++++++++------------ daemon/redis.h | 6 ++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/daemon/redis.c b/daemon/redis.c index 2c6d46017..8d33f0ec8 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -233,24 +233,21 @@ struct redis *redis_new(const endpoint_t *ep, int db, const char *auth, enum red r->db = db; r->auth = auth; r->role = role; + r->state = REDIS_STATE_DISCONNECTED; mutex_init(&r->lock); - if (redis_connect(r, 10)) - goto err; - - // redis is connected - if (r->state == REDIS_STATE_DISCONNECTED) { - rlog(LOG_INFO, "Established connection to Redis %s", + if (redis_connect(r, 10)) { + rlog(LOG_WARN, "Starting with no initial connection to Redis %s !", endpoint_print_buf(&r->endpoint)); - r->state = REDIS_STATE_CONNECTED; + return r; } - return r; + // redis is connected + rlog(LOG_INFO, "Established initial connection to Redis %s", + endpoint_print_buf(&r->endpoint)); + r->state = REDIS_STATE_CONNECTED; -err: - mutex_destroy(&r->lock); - g_slice_free1(sizeof(*r), r); - return NULL; + return r; } diff --git a/daemon/redis.h b/daemon/redis.h index fa7886da7..8c0e15348 100644 --- a/daemon/redis.h +++ b/daemon/redis.h @@ -20,8 +20,10 @@ enum redis_role { ANY_REDIS_ROLE = 2, }; -#define REDIS_STATE_DISCONNECTED 0 -#define REDIS_STATE_CONNECTED 1 +enum redis_state { + REDIS_STATE_DISCONNECTED = 0, + REDIS_STATE_CONNECTED = 1, +}; struct callmaster; struct call;