From e65f0150b87d7fcb7bc3233350effac2b133c27d Mon Sep 17 00:00:00 2001 From: zhangchengwei Date: Wed, 24 Oct 2018 10:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHEAD=20Redis=E6=97=B6BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/src/tango_cache_redis.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cache/src/tango_cache_redis.cpp b/cache/src/tango_cache_redis.cpp index dfc5e3b..b66f2eb 100644 --- a/cache/src/tango_cache_redis.cpp +++ b/cache/src/tango_cache_redis.cpp @@ -65,7 +65,7 @@ void redis_asyn_connect_cb(const struct redisAsyncContext *ac, int status) } 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; } } @@ -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")); } } + cJSON_Delete(root); return PARSE_JSON_RET_SUCC; 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->type == REDIS_REPLY_NIL) + if(reply!=NULL && reply->type == REDIS_REPLY_NIL) { tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS); ctx->get.result.type = RESULT_TYPE_MISS; @@ -176,9 +177,15 @@ void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, void *pri } 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); - promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); + 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)); + } } tango_cache_ctx_destroy(ctx); 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); 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); 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));