Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndb_redis: add disable server on failure feature #1116

Merged
merged 2 commits into from May 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/modules/ndb_redis/ndb_redis_mod.c
Expand Up @@ -48,8 +48,8 @@ int init_without_redis = 0;
int redis_connect_timeout_param = 1000;
int redis_cmd_timeout_param = 1000;
int redis_cluster_param = 0;
int disable_time=0;
int allowed_timeouts=-1;
int redis_disable_time_param=0;
int redis_allowed_timeouts_param=-1;

static int w_redis_cmd3(struct sip_msg* msg, char* ssrv, char* scmd,
char* sres);
Expand Down Expand Up @@ -122,8 +122,8 @@ static param_export_t params[]={
{"connect_timeout", INT_PARAM, &redis_connect_timeout_param},
{"cmd_timeout", INT_PARAM, &redis_cmd_timeout_param},
{"cluster", INT_PARAM, &redis_cluster_param},
{"disable_time", INT_PARAM, &disable_time},
{"allowed_timeouts", INT_PARAM, &allowed_timeouts},
{"disable_time", INT_PARAM, &redis_disable_time_param},
{"allowed_timeouts", INT_PARAM, &redis_allowed_timeouts_param},
{0, 0, 0}
};

Expand Down
12 changes: 6 additions & 6 deletions src/modules/ndb_redis/redis_client.c
Expand Up @@ -49,8 +49,8 @@ extern int init_without_redis;
extern int redis_connect_timeout_param;
extern int redis_cmd_timeout_param;
extern int redis_cluster_param;
extern int disable_time;
extern int allowed_timeouts;
extern int redis_disable_time_param;
extern int redis_allowed_timeouts_param;

/* backwards compatibility with hiredis < 0.12 */
#if (HIREDIS_MAJOR == 0) && (HIREDIS_MINOR < 12)
Expand Down Expand Up @@ -1043,17 +1043,17 @@ int redis_check_server(redisc_server_t *rsrv)

int redis_count_err_and_disable(redisc_server_t *rsrv)
{
if (allowed_timeouts < 0)
if (redis_allowed_timeouts_param < 0)
{
return 0;
}

rsrv->disable.consecutive_errors++;
if (rsrv->disable.consecutive_errors > allowed_timeouts)
if (rsrv->disable.consecutive_errors > redis_allowed_timeouts_param)
{
rsrv->disable.disabled=1;
rsrv->disable.restore_tick=get_ticks() + disable_time;
LM_WARN("REDIS server %.*s disabled for %d seconds",rsrv->sname->len,rsrv->sname->s,disable_time);
rsrv->disable.restore_tick=get_ticks() + redis_disable_time_param;
LM_WARN("REDIS server %.*s disabled for %d seconds",rsrv->sname->len,rsrv->sname->s,redis_disable_time_param);
return 1;
}
return 0;
Expand Down