Skip to content

Commit

Permalink
- Fix redis that during a reload it does not fail if the redis
Browse files Browse the repository at this point in the history
  server does not connect or does not respond. It still logs the
  errors and if the server is up checks expiration features.
  • Loading branch information
wcawijngaards committed Nov 4, 2024
1 parent 11b8157 commit 5f3f214
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cachedb/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ redis_init(struct module_env* env, struct cachedb_env* cachedb_env)
for(i = 0; i < moddata->numctxs; i++) {
redisContext* ctx = redis_connect(moddata);
if(!ctx) {
log_err("redis_init: failed to init redis");
goto fail;
log_err("redis_init: failed to init redis "
"(for thread %d)", i);
/* And continue, the context can be established
* later, just like after a disconnect. */
}
moddata->ctxs[i] = ctx;
}
cachedb_env->backend_data = moddata;
if(env->cfg->redis_expire_records) {
if(env->cfg->redis_expire_records &&
moddata->ctxs[env->alloc->thread_num] != NULL) {
redisReply* rep = NULL;
int redis_reply_type = 0;
/** check if setex command is supported */
Expand All @@ -199,7 +202,6 @@ redis_init(struct module_env* env, struct cachedb_env* cachedb_env)
log_err("redis_init: failed to init redis, the "
"redis-expire-records option requires the SETEX command "
"(redis >= 2.0.0)");
goto fail;
}
redis_reply_type = rep->type;
freeReplyObject(rep);
Expand All @@ -211,7 +213,6 @@ redis_init(struct module_env* env, struct cachedb_env* cachedb_env)
log_err("redis_init: failed to init redis, the "
"redis-expire-records option requires the SETEX command "
"(redis >= 2.0.0)");
goto fail;
}
}
return 1;
Expand Down

0 comments on commit 5f3f214

Please sign in to comment.