大文件流式缓存联调通过。UNDEFINE类型100KB以上进行缓存。
This commit is contained in:
4
cache/src/tango_cache_pending.cpp
vendored
4
cache/src/tango_cache_pending.cpp
vendored
@@ -273,6 +273,10 @@ enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_half *resp
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
const char *value = NULL;
|
const char *value = NULL;
|
||||||
memset(freshness,0,sizeof(struct response_freshness));
|
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);
|
value = tfe_http_std_field_read(response, TFE_HTTP_PRAGMA);
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -318,16 +318,19 @@ int main(int argc, char *argv[])
|
|||||||
evtimer_add(g_default_proxy->gcev , &gc_delay);
|
evtimer_add(g_default_proxy->gcev , &gc_delay);
|
||||||
|
|
||||||
/* WORKER THREAD */
|
/* WORKER THREAD */
|
||||||
|
//TODO: Split ctx_create functioin to create and Run.
|
||||||
for(unsigned tid = 0; tid < g_default_proxy->nr_work_threads; tid++)
|
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);
|
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);
|
CHECK_OR_EXIT(g_default_proxy->work_threads[tid], "Failed at creating thread %u", tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ACCEPTOR INIT */
|
/* ACCEPTOR INIT */
|
||||||
g_default_proxy->kni_acceptor_handler = kni_acceptor_init(g_default_proxy, main_profile, g_default_logger);
|
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. ");
|
CHECK_OR_EXIT(g_default_proxy->kni_acceptor_handler, "Failed at init KNI acceptor. Exit. ");
|
||||||
|
|
||||||
|
|
||||||
/* PLUGIN INIT */
|
/* PLUGIN INIT */
|
||||||
unsigned int plugin_iterator = 0;
|
unsigned int plugin_iterator = 0;
|
||||||
for(struct tfe_plugin * plugin_iter = tfe_plugin_iterate(&plugin_iterator);
|
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. ");
|
TFE_LOG_ERROR(g_default_logger, "Tango Frontend Engine initialized. ");
|
||||||
event_base_dispatch(g_default_proxy->evbase);
|
event_base_dispatch(g_default_proxy->evbase);
|
||||||
|
|
||||||
|
|||||||
@@ -139,12 +139,28 @@ struct cache_update_context* web_cache_update_start(struct cache_handle* handle,
|
|||||||
char buffer[TFE_STRING_MAX];
|
char buffer[TFE_STRING_MAX];
|
||||||
const char* value=NULL;
|
const char* value=NULL;
|
||||||
int i=0;
|
int i=0;
|
||||||
put_action=tfe_cache_put_pending(session->resp, &resp_freshness);
|
size_t content_len=0;
|
||||||
if(put_action!=ALLOWED)
|
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;
|
struct tango_cache_meta_put meta;
|
||||||
memset(&meta, 0, sizeof(meta));
|
memset(&meta, 0, sizeof(meta));
|
||||||
meta.url=session->req->req_spec.url;
|
meta.url=session->req->req_spec.url;
|
||||||
|
|||||||
@@ -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 */
|
* and has been call body_begin, construct the header */
|
||||||
if (hf_private->evbuf_body != NULL && hf_private->write_ctx == NULL)
|
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
|
/* 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 */
|
* Otherwise, means the body is ready, send out directly without frag */
|
||||||
|
|||||||
@@ -657,7 +657,7 @@ int hf_ops_body_end(struct tfe_http_half * half)
|
|||||||
hf_private->body_status = STATUS_COMPLETE;
|
hf_private->body_status = STATUS_COMPLETE;
|
||||||
hf_private->message_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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user