完善redis出错处理。

This commit is contained in:
zhengchao
2017-10-11 20:55:25 +08:00
parent 0f5f87ef69
commit 7605450f0f
3 changed files with 16 additions and 3 deletions

View File

@@ -488,6 +488,12 @@ FULL_UPDATE:
reply=NULL;
}
reply=_wrap_redisCommand(c,"EXEC");
if(reply==NULL)
{
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,
"Redis Communication error: %s.",c->errstr);
return -1;
}
assert(reply->type==REDIS_REPLY_ARRAY);
*new_version=read_redis_integer(reply->element[0]);
sub_reply=reply->element[1];

View File

@@ -1,4 +1,4 @@
LIBS= ../lib/libmaatframe.so -lhiredis_vip
LIBS= -lmaatframe -lhiredis_vip
INC=-I../inc/ -I ../src/entry/ -I../src/inc_internal/ -I/usr/include/MESA/
all:
g++ -o maat_redis_tool.o -c -g -Wall maat_redis_tool.cpp $(INC)

View File

@@ -62,6 +62,12 @@ void read_rule_from_redis(const char*redis_ip, int redis_port, int redis_db,cons
printf("No Effective Rules.\n");
return;
}
if(rule_num<0)
{
printf("Read Redis Error.\n");
return;
}
assert(update_type==CM_UPDATE_TYPE_FULL);
printf("MAAT Version: %d, key number: %d\n", version, rule_num);
printf("Reading value: ");
@@ -70,6 +76,7 @@ void read_rule_from_redis(const char*redis_ip, int redis_port, int redis_db,cons
{
goto clean_up;
}
printf("Sorting.\n");
qsort(rule_list,rule_num, sizeof(struct serial_rule_t),
compare_serial_rule);
if((access(output_path,F_OK)) <0)
@@ -142,7 +149,7 @@ clean_up:
int main(int argc, char * argv[])
{
int oc=0;
char model='?';
//char model='?';
char redis_ip[64];
int redis_port=6379;
int redis_db=0;
@@ -156,7 +163,7 @@ int main(int argc, char * argv[])
switch(oc)
{
case 'm':
model=oc;
//model=oc;
break;
case 'h':
strncpy(redis_ip,optarg,sizeof(redis_ip));