From 92698c981022243dc0d73017c78debbbaa14ab0e Mon Sep 17 00:00:00 2001 From: zhengchao Date: Wed, 31 Oct 2018 11:52:19 +0800 Subject: [PATCH] =?UTF-8?q?pangu=20http=E4=B8=9A=E5=8A=A1=E5=B1=82?= =?UTF-8?q?=E9=80=82=E9=85=8Dcache=20client=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/src/tango_cache_redis.cpp | 2 +- .../pangu-http/src/pangu_web_cache.cpp | 23 +++++++++++++++---- vendor/CMakeLists.txt | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/cache/src/tango_cache_redis.cpp b/cache/src/tango_cache_redis.cpp index e234011..1d0b583 100644 --- a/cache/src/tango_cache_redis.cpp +++ b/cache/src/tango_cache_redis.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "tango_cache_transfer.h" #include "tango_cache_tools.h" diff --git a/plugin/business/pangu-http/src/pangu_web_cache.cpp b/plugin/business/pangu-http/src/pangu_web_cache.cpp index 71355d2..eae6a3e 100644 --- a/plugin/business/pangu-http/src/pangu_web_cache.cpp +++ b/plugin/business/pangu-http/src/pangu_web_cache.cpp @@ -408,7 +408,13 @@ void cache_pending_ctx_free_cb(void* p) { struct cache_pending_context* ctx=(struct cache_pending_context*)p; ctx->request=NULL; - free(ctx->url); + FREE(&(ctx->url)); + FREE(&(ctx->req_if_modified_since)); + FREE(&(ctx->req_if_none_match)); + if(ctx->f_tango_cache_fetch) + { + future_destroy(ctx->f_tango_cache_fetch); + } free(ctx); return; } @@ -519,8 +525,13 @@ enum cache_pending_result web_cache_async_pending(struct cache_handle* handle, u promise_set_ctx(p, ctx, cache_pending_ctx_free_cb); ATOMIC_INC(&(handle->stat_val[STAT_CACHE_PENDING])); - ctx->f_tango_cache_fetch=future_create("_cache_meta", cache_query_meta_on_succ, cache_query_meta_on_fail, p); + ctx->f_tango_cache_fetch=future_create("_cache_pend", cache_query_meta_on_succ, cache_query_meta_on_fail, p); int ret=tango_cache_head_object(handle->clients[thread_id], ctx->f_tango_cache_fetch, &meta); + if(ret<0) + { + cache_pending_ctx_free_cb(ctx); + return PENDING_RESULT_FOBIDDEN; + } assert(ret==0); return PENDING_RESULT_REVALIDATE; } @@ -555,7 +566,12 @@ int web_cache_async_query(struct cache_handle* handle, unsigned int thread_id, ATOMIC_INC(&(handle->stat_val[STAT_CACHE_QUERYING])); query_ctx->f_tango_cache_fetch=future_create("_cache_get", cache_query_obj_on_succ, cache_query_obj_on_fail, p); - int ret=tango_cache_fetch_object(handle->clients[thread_id], query_ctx->f_tango_cache_fetch, &meta); + int ret=tango_cache_fetch_object(handle->clients[thread_id], query_ctx->f_tango_cache_fetch, &meta); + if(ret<0) + { + cache_query_ctx_free_cb(query_ctx); + return -1; + } return 0; } struct wrap_cache_put_ctx @@ -658,7 +674,6 @@ struct cache_update_context* web_cache_update_start(struct cache_handle* handle, if(write_ctx==NULL)//exceed maximum cache memory size. { wrap_cache_put_ctx_free(_cache_put_ctx); - assert(0); return NULL; } TFE_LOG_DEBUG(handle->logger, "cache upload allowed: %s", _cache_put_ctx->url); diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 7ccaf2c..970d191 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -249,8 +249,8 @@ set_property(TARGET libcurl-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib set_property(TARGET libcurl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) ExternalProject_Add(hiredis PREFIX hiredis - URL ${CMAKE_CURRENT_SOURCE_DIR}/hiredis-0.14.0-modified.zip - URL_MD5 d093a1868529ee37183d72988936bce3 + URL ${CMAKE_CURRENT_SOURCE_DIR}/hiredis-0.14.0.zip + URL_MD5 376af92277701fae52a8c917c3ce3044 CONFIGURE_COMMAND "" BUILD_COMMAND make INSTALL_COMMAND make install