Browse Source

* allow redis source/backend fail on start

master
Alex 'AdUser' Z 7 years ago
parent
commit
694624036c
  1. 18
      src/backends/redis.c
  2. 12
      src/sources/redis.c

18
src/backends/redis.c

@ -91,8 +91,10 @@ static bool
redis_disconnect(cfg_t *cfg) { redis_disconnect(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
redisFree(cfg->conn); if (cfg->conn) {
cfg->conn = NULL; redisFree(cfg->conn);
cfg->conn = NULL;
}
return true; return true;
} }
@ -170,10 +172,11 @@ bool
start(cfg_t *cfg) { start(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
if (cfg->shared && usage_inc(cfg->name) > 1) if (cfg->shared)
return true; usage_inc(cfg->name);
return redis_connect(cfg); redis_connect(cfg); /* may fail */
return true;
} }
bool bool
@ -181,9 +184,10 @@ stop(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
if (cfg->shared && usage_dec(cfg->name) > 0) if (cfg->shared && usage_dec(cfg->name) > 0)
return true; return true; /* skip disconnect, if not last user */
return redis_disconnect(cfg); redis_disconnect(cfg);
return true;
} }
bool bool

12
src/sources/redis.c

@ -99,8 +99,10 @@ static bool
redis_disconnect(cfg_t *cfg) { redis_disconnect(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
redisFree(cfg->conn); if (cfg->conn) {
cfg->conn = NULL; redisFree(cfg->conn);
cfg->conn = NULL;
}
return true; return true;
} }
@ -180,14 +182,16 @@ bool
start(cfg_t *cfg) { start(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
return redis_connect(cfg); redis_connect(cfg); /* may fail */
return true;
} }
bool bool
stop(cfg_t *cfg) { stop(cfg_t *cfg) {
assert(cfg != NULL); assert(cfg != NULL);
return redis_disconnect(cfg); redis_disconnect(cfg);
return true;
} }
bool bool

Loading…
Cancel
Save