修复HEAD Redis时BUG

This commit is contained in:
zhangchengwei
2018-10-24 10:04:58 +08:00
committed by zhengchao
parent 232b08c43a
commit e65f0150b8

View File

@@ -65,7 +65,7 @@ void redis_asyn_connect_cb(const struct redisAsyncContext *ac, int status)
} }
else else
{ {
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_INFO, "Redis connect %s:%u failed.", instance->redis_ip, instance->redis_port, ac->errstr); MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_INFO, "Redis connect %s:%u failed: %s.", instance->redis_ip, instance->redis_port, ac->errstr);
instance->redis_connecting = CACHE_REDIS_CONNECT_IDLE; instance->redis_connecting = CACHE_REDIS_CONNECT_IDLE;
} }
} }
@@ -152,6 +152,7 @@ int parse_minio_events_json(struct tango_cache_ctx *ctx, const char *jcontent)
easy_string_savedata(&ctx->response, "\r\n", strlen("\r\n")); easy_string_savedata(&ctx->response, "\r\n", strlen("\r\n"));
} }
} }
cJSON_Delete(root);
return PARSE_JSON_RET_SUCC; return PARSE_JSON_RET_SUCC;
out_json: out_json:
@@ -167,7 +168,7 @@ void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, void *pri
if(reply == NULL || reply->type!=REDIS_REPLY_STRING) if(reply == NULL || reply->type!=REDIS_REPLY_STRING)
{ {
if(reply->type == REDIS_REPLY_NIL) if(reply!=NULL && reply->type == REDIS_REPLY_NIL)
{ {
tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS); tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS);
ctx->get.result.type = RESULT_TYPE_MISS; ctx->get.result.type = RESULT_TYPE_MISS;
@@ -176,10 +177,16 @@ void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, void *pri
} }
else else
{ {
if(ac->err) MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_FATAL, "redis_hget_command_cb error: %s.", ac->errstr);
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON); tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON);
if(reply!=NULL && reply->type==REDIS_REPLY_ERROR)
{
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, reply->str);
}
else
{
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
} }
}
tango_cache_ctx_destroy(ctx); tango_cache_ctx_destroy(ctx);
return; return;
} }
@@ -221,7 +228,7 @@ int tango_cache_head_redis(struct tango_cache_ctx *ctx)
ctx->instance->redis_key, ctx->instance->bucketname, ctx->object_key); ctx->instance->redis_key, ctx->instance->bucketname, ctx->object_key);
if(ret < 0) if(ret < 0)
{ {
redisAsyncDisconnect(ctx->instance->redis_ac); //redisAsyncDisconnect(ctx->instance->redis_ac);
redis_asyn_connect_init(ctx->instance, ctx->instance->redis_ip, ctx->instance->redis_port); redis_asyn_connect_init(ctx->instance, ctx->instance->redis_ip, ctx->instance->redis_port);
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_CONNECT); tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_CONNECT);
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));