在Redis配置格式非法时,输出错误信息。
This commit is contained in:
@@ -3,7 +3,7 @@ project(maatframe)
|
|||||||
|
|
||||||
set(MAAT_FRAME_MAJOR_VERSION 2)
|
set(MAAT_FRAME_MAJOR_VERSION 2)
|
||||||
set(MAAT_FRAME_MINOR_VERSION 3)
|
set(MAAT_FRAME_MINOR_VERSION 3)
|
||||||
set(MAAT_FRAME_PATCH_VERSION 20180926)
|
set(MAAT_FRAME_PATCH_VERSION 20181025)
|
||||||
set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION})
|
set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION})
|
||||||
|
|
||||||
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")
|
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ int get_inc_key_list(long long instance_version, long long target_version, redis
|
|||||||
char err_buff[256], op_str[4];
|
char err_buff[256], op_str[4];
|
||||||
int rule_num=0;
|
int rule_num=0;
|
||||||
UNUSED int ret=0;
|
UNUSED int ret=0;
|
||||||
unsigned int i=0;
|
unsigned int i=0, j=0;
|
||||||
long long nearest_rule_version;
|
long long nearest_rule_version;
|
||||||
struct serial_rule_t *s_rule=NULL;
|
struct serial_rule_t *s_rule=NULL;
|
||||||
|
|
||||||
@@ -388,25 +388,33 @@ int get_inc_key_list(long long instance_version, long long target_version, redis
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
s_rule=(struct serial_rule_t*)calloc(reply->elements,sizeof(struct serial_rule_t));
|
s_rule=(struct serial_rule_t*)calloc(reply->elements,sizeof(struct serial_rule_t));
|
||||||
for(i=0;i<reply->elements;i++)
|
for(i=0, j=0;i<reply->elements;i++)
|
||||||
{
|
{
|
||||||
assert(reply->element[i]->type==REDIS_REPLY_STRING);
|
assert(reply->element[i]->type==REDIS_REPLY_STRING);
|
||||||
ret=sscanf(reply->element[i]->str,"%[^,],%[^,],%d",op_str,s_rule[i].table_name,&(s_rule[i].rule_id));
|
ret=sscanf(reply->element[i]->str,"%[^,],%[^,],%d",op_str,s_rule[j].table_name,&(s_rule[j].rule_id));
|
||||||
assert(ret==3);
|
if(ret!=3||s_rule[i].rule_id<0)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
|
"Invalid Redis Key: %s",reply->element[i]->str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(strncmp(op_str,"ADD",strlen("ADD"))==0)
|
if(strncmp(op_str,"ADD",strlen("ADD"))==0)
|
||||||
{
|
{
|
||||||
s_rule[i].op=MAAT_OP_ADD;
|
s_rule[j].op=MAAT_OP_ADD;
|
||||||
}
|
}
|
||||||
else if(strncmp(op_str,"DEL",strlen("DEL"))==0)
|
else if(strncmp(op_str,"DEL",strlen("DEL"))==0)
|
||||||
{
|
{
|
||||||
s_rule[i].op=MAAT_OP_DEL;
|
s_rule[j].op=MAAT_OP_DEL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0);
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
|
"Invalid Redis Key: %s",reply->element[i]->str);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
rule_num=reply->elements;
|
rule_num=j;
|
||||||
*list=s_rule;
|
*list=s_rule;
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
return rule_num;
|
return rule_num;
|
||||||
@@ -607,19 +615,45 @@ FULL_UPDATE:
|
|||||||
"Redis Communication error: %s.",c->errstr);
|
"Redis Communication error: %s.",c->errstr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
assert(reply->type==REDIS_REPLY_ARRAY);
|
if(reply->type!=REDIS_REPLY_ARRAY)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
|
"Invalid Redis Key List type %d", sub_reply->type);
|
||||||
|
freeReplyObject(reply);
|
||||||
|
reply=NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
*new_version=read_redis_integer(reply->element[0]);
|
*new_version=read_redis_integer(reply->element[0]);
|
||||||
sub_reply=reply->element[1];
|
sub_reply=reply->element[1];
|
||||||
assert(sub_reply->type==REDIS_REPLY_ARRAY);
|
if(sub_reply->type!=REDIS_REPLY_ARRAY)
|
||||||
rule_num=sub_reply->elements;
|
|
||||||
s_rule_array=(struct serial_rule_t*)calloc(rule_num,sizeof(struct serial_rule_t));
|
|
||||||
for(full_idx=0;full_idx<sub_reply->elements;full_idx++)
|
|
||||||
{
|
{
|
||||||
assert(sub_reply->element[full_idx]->type==REDIS_REPLY_STRING);
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
ret=sscanf(sub_reply->element[full_idx]->str,"%*[^:]:%[^,],%d",s_rule_array[full_idx].table_name,&(s_rule_array[full_idx].rule_id));
|
"Invalid Redis Key List type %d", sub_reply->type);
|
||||||
s_rule_array[full_idx].op=MAAT_OP_ADD;
|
freeReplyObject(reply);
|
||||||
assert(ret==2);
|
reply=NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_rule_array=(struct serial_rule_t*)calloc(sub_reply->elements,sizeof(struct serial_rule_t));
|
||||||
|
for(i=0, full_idx=0; i<sub_reply->elements; i++)
|
||||||
|
{
|
||||||
|
if(sub_reply->element[i]->type!=REDIS_REPLY_STRING)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
|
"Invalid Redis Key Type: %d", sub_reply->element[i]->type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ret=sscanf(sub_reply->element[i]->str,"%*[^:]:%[^,],%d",s_rule_array[full_idx].table_name,&(s_rule_array[full_idx].rule_id));
|
||||||
|
s_rule_array[full_idx].op=MAAT_OP_ADD;
|
||||||
|
if(ret!=2||s_rule_array[full_idx].rule_id<0||strlen(s_rule_array[full_idx].table_name)==0)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
|
||||||
|
"Invalid Redis Key Format: %s", sub_reply->element[i]->str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
full_idx++;
|
||||||
|
}
|
||||||
|
rule_num=full_idx;
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
if(desired_version!=0)
|
if(desired_version!=0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "stream_fuzzy_hash.h"
|
#include "stream_fuzzy_hash.h"
|
||||||
#include "gram_index_engine.h"
|
#include "gram_index_engine.h"
|
||||||
|
|
||||||
int MAAT_FRAME_VERSION_2_2_20180926=1;
|
int MAAT_FRAME_VERSION_2_2_20181025=1;
|
||||||
|
|
||||||
const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin",
|
const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin",
|
||||||
"unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""};
|
"unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""};
|
||||||
|
|||||||
Reference in New Issue
Block a user