修复限流Handle未初始化db_index问题

This commit is contained in:
fengweihao
2020-06-08 17:17:07 +08:00
parent ed19fc177e
commit aadb00755f
2 changed files with 4 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ enable=0
token_name=ratelimit token_name=ratelimit
redis_server=192.168.40.137 redis_server=192.168.40.137
redis_port=6379 redis_port=6379
redis_db_index=5
[maat] [maat]
# 0:json 1: redis 2: iris # 0:json 1: redis 2: iris

View File

@@ -988,6 +988,7 @@ error_out:
Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const char* static_section) Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const char* static_section)
{ {
int ret=0, field_stat=0; int ret=0, field_stat=0;
int redis_db_idx = 0;
int redis_port = 0, interval_sec = 0; int redis_port = 0, interval_sec = 0;
char redis_server[TFE_STRING_MAX] = {0}; char redis_server[TFE_STRING_MAX] = {0};
char token_name[TFE_STRING_MAX] = {0}; char token_name[TFE_STRING_MAX] = {0};
@@ -998,6 +999,7 @@ Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const cha
MESA_load_profile_int_def(profile_path, static_section, "redis_port", &(redis_port), 6379); MESA_load_profile_int_def(profile_path, static_section, "redis_port", &(redis_port), 6379);
MESA_load_profile_string_def(profile_path, static_section, "redis_server", redis_server, sizeof(redis_server), ""); MESA_load_profile_string_def(profile_path, static_section, "redis_server", redis_server, sizeof(redis_server), "");
MESA_load_profile_string_def(profile_path, static_section, "token_name", token_name, sizeof(token_name), ""); MESA_load_profile_string_def(profile_path, static_section, "token_name", token_name, sizeof(token_name), "");
MESA_load_profile_int_def(profile_path, static_section, "redis_db_index", &(redis_db_idx), 0);
MESA_load_profile_int_def(profile_path, static_section, "interval_sec", &(interval_sec), 1); MESA_load_profile_int_def(profile_path, static_section, "interval_sec", &(interval_sec), 1);
if (g_pangu_rt->enable_rate != 1) if (g_pangu_rt->enable_rate != 1)
@@ -1008,6 +1010,7 @@ Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const cha
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_INTERVAL_SEC, &interval_sec, sizeof(interval_sec)); Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_INTERVAL_SEC, &interval_sec, sizeof(interval_sec));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_IP, redis_server, strlen(redis_server) + 1); Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_IP, redis_server, strlen(redis_server) + 1);
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_PORT, &redis_port, sizeof(redis_port)); Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_PORT, &redis_port, sizeof(redis_port));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_INDEX, &redis_db_idx, sizeof(redis_db_idx));
/*field stata for debug test**/ /*field stata for debug test**/
MESA_load_profile_int_def(profile_path, static_section, "field_stat", &(field_stat), 0); MESA_load_profile_int_def(profile_path, static_section, "field_stat", &(field_stat), 0);