From 5666787f67e6c5a9a6110e5dca349ec7b65de726 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Fri, 21 Dec 2018 14:31:27 +0600 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E8=81=94=E8=B0=83=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E3=80=82=E4=BF=AE=E6=AD=A3force=20caching=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=85=88=E7=BA=A7=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/pangu-http/src/pangu_web_cache.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugin/business/pangu-http/src/pangu_web_cache.cpp b/plugin/business/pangu-http/src/pangu_web_cache.cpp index b824c1e..04fb972 100644 --- a/plugin/business/pangu-http/src/pangu_web_cache.cpp +++ b/plugin/business/pangu-http/src/pangu_web_cache.cpp @@ -1221,6 +1221,7 @@ static void wrap_cache_write_on_fail(enum e_future_error err, const char * what, struct cache_write_future_ctx* ctx=(struct cache_write_future_ctx*)user; TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload failed: %s %s lapse: %d", ctx->url, what, time(NULL)-ctx->start); cache_write_future_ctx_free(ctx); + ATOMIC_INC(&(ctx->ref_handle->stat_val[STAT_CACHE_WRITE_ERR])); } struct cache_write_context* web_cache_write_start(struct cache_handle* handle, unsigned int thread_id, @@ -1268,11 +1269,16 @@ struct cache_write_context* web_cache_write_start(struct cache_handle* handle, u case REVALIDATE: case ALLOWED: case UNDEFINED: - if(_mid->shall_bypass + if(param->force_caching) + { + break; + } + else if(_mid->shall_bypass || (param->max_cache_obj_size!=0 && content_len > param->max_cache_obj_size) || (param->min_cache_obj_size > content_len) || (!param->cache_cookied_cont && _mid->has_cookie) - || (!param->cache_html && _mid->is_html)) + || (!param->cache_html && _mid->is_html) + ) { ATOMIC_INC(&(handle->stat_val[STAT_CACHE_WRITE_BYPASS])); return NULL; @@ -1376,9 +1382,10 @@ void web_cache_write_end(struct cache_write_context* ctx) if(ret<0) { //upload too slow or storage server error; - cache_write_future_ctx_free(future_ctx); TFE_LOG_DEBUG(ctx->ref_cache_handle->logger, "cache upload failed: %s",ctx->future_ctx->url); - return; + cache_write_future_ctx_free(ctx->future_ctx); + ctx->future_ctx=NULL; + ATOMIC_INC(&(ctx->ref_cache_handle->stat_val[STAT_CACHE_WRITE_ERR])); } } else