From ef7e2831a478dc15b6f263065dba114b194b26ec Mon Sep 17 00:00:00 2001 From: zhengchao Date: Thu, 29 Nov 2018 10:46:46 +0800 Subject: [PATCH] =?UTF-8?q?#96=20=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2promise=5Fallow=5Fmany=5Fsuccesses=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=9C=AA=E8=B0=83=E7=94=A8promise=5Ffinish=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/pangu-http/src/pangu_web_cache.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugin/business/pangu-http/src/pangu_web_cache.cpp b/plugin/business/pangu-http/src/pangu_web_cache.cpp index 9595487..b090d8c 100644 --- a/plugin/business/pangu-http/src/pangu_web_cache.cpp +++ b/plugin/business/pangu-http/src/pangu_web_cache.cpp @@ -885,7 +885,8 @@ static void cache_query_obj_on_succ(future_result_t * result, void * user) case RESULT_TYPE_END: //last call. ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_READING])); - promise_dettach_ctx(p); + promise_dettach_ctx(p); + promise_finish(p); last_call=1; break; case RESULT_TYPE_BODY: @@ -903,7 +904,8 @@ static void cache_query_obj_on_fail(enum e_future_error err, const char * what, { struct promise * p = (struct promise *) user; struct cache_query_context* ctx=(struct cache_query_context*)promise_dettach_ctx(p); - promise_failed(p, err, what); + promise_failed(p, err, what); + promise_finish(p); ATOMIC_DEC(&(ctx->ref_handle->stat_val[STAT_CACHE_READING])); cache_query_ctx_free_cb(ctx); return; @@ -1189,7 +1191,7 @@ struct wrap_cache_put_ctx struct future* f; struct cache_handle* ref_handle; }; -void wrap_cache_put_ctx_free(struct wrap_cache_put_ctx* ctx) +void wrap_cache_write_ctx_free(struct wrap_cache_put_ctx* ctx) { FREE(&(ctx->url)); future_destroy(ctx->f); @@ -1199,13 +1201,13 @@ static void wrap_cache_write_on_succ(future_result_t * result, void * user) { struct wrap_cache_put_ctx* ctx=(struct wrap_cache_put_ctx*)user; TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload success: %s elapse: %d", ctx->url, time(NULL)-ctx->start); - wrap_cache_put_ctx_free(ctx); + wrap_cache_write_ctx_free(ctx); } static void wrap_cache_write_on_fail(enum e_future_error err, const char * what, void * user) { struct wrap_cache_put_ctx* ctx=(struct wrap_cache_put_ctx*)user; TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload failed: %s %s lapse: %d", ctx->url, what, time(NULL)-ctx->start); - wrap_cache_put_ctx_free(ctx); + wrap_cache_write_ctx_free(ctx); } struct cache_update_context* web_cache_write_start(struct cache_handle* handle, unsigned int thread_id, @@ -1325,7 +1327,7 @@ struct cache_update_context* web_cache_write_start(struct cache_handle* handle, write_ctx=tango_cache_update_start(handle->clients[thread_id], _cache_put_ctx->f, &meta); if(write_ctx==NULL)//exceed maximum cache memory size. { - wrap_cache_put_ctx_free(_cache_put_ctx); + wrap_cache_write_ctx_free(_cache_put_ctx); return NULL; } TFE_LOG_DEBUG(handle->logger, "cache upload allowed: %s", _cache_put_ctx->url);