支持在应答侧suspend/resume功能,合并http_entry中处理request/response的流程
This commit is contained in:
@@ -348,7 +348,7 @@ static int __parser_callback_on_headers_complete(http_parser * parser)
|
||||
|
||||
/* user's suspend tag is set, which indicate that the way to handle request/response
|
||||
* cannot be determinate at now, need to defer */
|
||||
else if (hs_private && hs_private->suspend_tag_effective)
|
||||
else if (hs_private && hs_private->suspend_tag_signal)
|
||||
{
|
||||
/* Pause parser, prevent to parse request/response body,
|
||||
* The body should be parsed after resume() */
|
||||
@@ -829,13 +829,7 @@ void hs_ops_suspend(struct tfe_http_session * session)
|
||||
struct http_session_private * hs_private = to_hs_private(session);
|
||||
struct http_connection_private * hc_private = hs_private->hc_private;
|
||||
|
||||
hs_private->release_lock++;
|
||||
hs_private->suspend_counter++;
|
||||
hs_private->suspend_tag_effective = true;
|
||||
|
||||
tfe_stream_suspend(hc_private->stream, CONN_DIR_DOWNSTREAM);
|
||||
fprintf(stderr, "---- suspend ----, url = %s, counter = %d\n",
|
||||
hs_private->hs_public.req->req_spec.url, hs_private->suspend_counter);
|
||||
hs_private->suspend_tag_signal = true;
|
||||
}
|
||||
|
||||
void hs_ops_resume(struct tfe_http_session * session)
|
||||
@@ -844,15 +838,11 @@ void hs_ops_resume(struct tfe_http_session * session)
|
||||
struct http_connection_private * hc_private = hs_private->hc_private;
|
||||
|
||||
assert(!hs_private->in_gc_queue);
|
||||
|
||||
hs_private->release_lock--;
|
||||
if (hs_private->suspend_tag_effective)
|
||||
{
|
||||
tfe_stream_resume(hc_private->stream);
|
||||
hs_private->resume_tag_singal = true;
|
||||
}
|
||||
|
||||
fprintf(stderr, "---- resume ----, url = %s, counter = %d\n",
|
||||
hs_private->hs_public.req->req_spec.url, hs_private->suspend_counter);
|
||||
}
|
||||
|
||||
// TODO: change the return type to int, there is something happend where -1 returned.
|
||||
@@ -1128,10 +1118,17 @@ void __write_access_log(struct http_session_private * hs_private)
|
||||
const char * __str_req_passthrough = request ? request->is_passthrough ? "PASS-THROUGH/REQ" : "-" : "-";
|
||||
const char * __str_resp_passthrough = response ? response->is_passthrough ? "PASS-THROUGH/REP" : "-" : "-";
|
||||
|
||||
/* USER SETUP REQUEST/RESPONSE */
|
||||
const char * __str_user_req = hs_private->hf_private_req_user ? "USER/REQ" : "-";
|
||||
const char * __str_user_resp = hs_private->hf_private_resp_user ? "USER/RESP" : "-";
|
||||
|
||||
/* SUSPEND */
|
||||
const char * __str_suspend = hs_private->suspend_counter > 0 ? "SUSPEND" : "-";
|
||||
|
||||
char * __access_log;
|
||||
asprintf(&__access_log, "%d %s %s HTTP/%d.%d %s %s %s %s %s %s", hs_private->hs_public.session_id, __str_method,
|
||||
asprintf(&__access_log, "%d %s %s HTTP/%d.%d %s %s %s %s %s %s %s %s %s", hs_private->hs_public.session_id, __str_method,
|
||||
__str_url, request->major, request->minor, __str_resp_code, __str_cont_type, __str_cont_encoding,
|
||||
__str_upgrade, __str_req_passthrough, __str_resp_passthrough);
|
||||
__str_upgrade, __str_req_passthrough, __str_resp_passthrough, __str_user_req, __str_user_resp, __str_suspend);
|
||||
|
||||
const struct tfe_stream * stream = hs_private->hc_private->stream;
|
||||
tfe_stream_write_access_log(stream, RLOG_LV_INFO, "%s", __access_log);
|
||||
@@ -1157,11 +1154,13 @@ void hs_private_destroy(struct http_session_private * hs_private)
|
||||
|
||||
if (hs_private->hf_private_req_user)
|
||||
{
|
||||
assert(hs_private->hf_private_req_user->message_status == STATUS_COMPLETE);
|
||||
hf_private_destory(hs_private->hf_private_req_user);
|
||||
}
|
||||
|
||||
if (hs_private->hf_private_resp_user)
|
||||
{
|
||||
assert(hs_private->hf_private_resp_user->message_status == STATUS_COMPLETE);
|
||||
hf_private_destory(hs_private->hf_private_resp_user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user