diff --git a/cache/src/tango_cache_pending.cpp b/cache/src/tango_cache_pending.cpp index dc3eea0..67b935d 100644 --- a/cache/src/tango_cache_pending.cpp +++ b/cache/src/tango_cache_pending.cpp @@ -273,6 +273,10 @@ enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_half *resp int index = 0; const char *value = NULL; memset(freshness,0,sizeof(struct response_freshness)); + if(response->resp_spec.resp_code!=TFE_HTTP_STATUS_OK) + { + return FORBIDDEN; + } value = tfe_http_std_field_read(response, TFE_HTTP_PRAGMA); if (value != NULL) { diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index e986594..c10c399 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -318,16 +318,19 @@ int main(int argc, char *argv[]) evtimer_add(g_default_proxy->gcev , &gc_delay); /* WORKER THREAD */ + //TODO: Split ctx_create functioin to create and Run. for(unsigned tid = 0; tid < g_default_proxy->nr_work_threads; tid++) { g_default_proxy->work_threads[tid] = __thread_ctx_create(g_default_proxy, tid); CHECK_OR_EXIT(g_default_proxy->work_threads[tid], "Failed at creating thread %u", tid); } + /* ACCEPTOR INIT */ g_default_proxy->kni_acceptor_handler = kni_acceptor_init(g_default_proxy, main_profile, g_default_logger); CHECK_OR_EXIT(g_default_proxy->kni_acceptor_handler, "Failed at init KNI acceptor. Exit. "); + /* PLUGIN INIT */ unsigned int plugin_iterator = 0; for(struct tfe_plugin * plugin_iter = tfe_plugin_iterate(&plugin_iterator); @@ -339,6 +342,7 @@ int main(int argc, char *argv[]) } + TFE_LOG_ERROR(g_default_logger, "Tango Frontend Engine initialized. "); event_base_dispatch(g_default_proxy->evbase); diff --git a/plugin/business/pangu-http/pangu_web_cache.cpp b/plugin/business/pangu-http/pangu_web_cache.cpp index 89b8a60..7f74138 100644 --- a/plugin/business/pangu-http/pangu_web_cache.cpp +++ b/plugin/business/pangu-http/pangu_web_cache.cpp @@ -139,12 +139,28 @@ struct cache_update_context* web_cache_update_start(struct cache_handle* handle, char buffer[TFE_STRING_MAX]; const char* value=NULL; int i=0; - put_action=tfe_cache_put_pending(session->resp, &resp_freshness); - if(put_action!=ALLOWED) + size_t content_len=0; + if(session->resp->resp_spec.content_length!=NULL) { - return NULL; + sscanf(session->resp->resp_spec.content_length, "%lu", &content_len); + } + put_action=tfe_cache_put_pending(session->resp, &resp_freshness); + switch(put_action){ + case FORBIDDEN: + case VERIFY: + return NULL; + case ALLOWED: + break; + case UNDEFINED: + if(content_len<100*1024) + { + return NULL; + } + break; + default: + assert(0); + break; } - struct tango_cache_meta_put meta; memset(&meta, 0, sizeof(meta)); meta.url=session->req->req_spec.url; diff --git a/plugin/protocol/http/src/http_entry.cpp b/plugin/protocol/http/src/http_entry.cpp index 6769875..5e5ad50 100644 --- a/plugin/protocol/http/src/http_entry.cpp +++ b/plugin/protocol/http/src/http_entry.cpp @@ -87,7 +87,7 @@ static int __write_http_half_to_line(const struct tfe_stream * stream, * and has been call body_begin, construct the header */ if (hf_private->evbuf_body != NULL && hf_private->write_ctx == NULL) { - printf("frag write start, stream = %p, hf_private = %p\n", stream, hf_private); +// printf("frag write start, stream = %p, hf_private = %p\n", stream, hf_private); /* Still need to send data(not call body_end()), need to write frag start * Otherwise, means the body is ready, send out directly without frag */ diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp index d208c64..b5696ab 100644 --- a/plugin/protocol/http/src/http_half.cpp +++ b/plugin/protocol/http/src/http_half.cpp @@ -657,7 +657,7 @@ int hf_ops_body_end(struct tfe_http_half * half) hf_private->body_status = STATUS_COMPLETE; hf_private->message_status = STATUS_COMPLETE; - printf("frag write end, stream = %p, hf_private = %p\n", hf_private->session->hc_private->stream, hf_private); +// printf("frag write end, stream = %p, hf_private = %p\n", hf_private->session->hc_private->stream, hf_private); return 0; }