增加HTTP Session延迟回收机制,完善HTTP Session销毁流程
This commit is contained in:
@@ -588,6 +588,8 @@ int hf_ops_append_body(struct tfe_http_half * half, char * buff, size_t size, in
|
||||
int hf_ops_body_begin(struct tfe_http_half * half, int by_stream)
|
||||
{
|
||||
struct http_half_private * hf_private = to_hf_private(half);
|
||||
struct http_session_private * hs_private = hf_private->session;
|
||||
|
||||
assert(hf_private->evbuf_body == NULL);
|
||||
|
||||
if (by_stream)
|
||||
@@ -602,6 +604,9 @@ int hf_ops_body_begin(struct tfe_http_half * half, int by_stream)
|
||||
|
||||
hf_private->content_encoding = HTTP_ACCEPT_ENCODING_NONE;
|
||||
hf_private->is_setup_by_stream = true;
|
||||
|
||||
hs_private->stream_write_tag_effective = true;
|
||||
hs_private->release_lock++;
|
||||
}
|
||||
|
||||
hf_private->evbuf_body = evbuffer_new();
|
||||
@@ -649,6 +654,8 @@ __out:
|
||||
int hf_ops_body_end(struct tfe_http_half * half)
|
||||
{
|
||||
struct http_half_private * hf_private = to_hf_private(half);
|
||||
struct http_session_private * hs_private = hf_private->session;
|
||||
|
||||
if (hf_private->write_ctx)
|
||||
{
|
||||
tfe_stream_write_frag_end(hf_private->write_ctx);
|
||||
@@ -658,7 +665,13 @@ 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);
|
||||
if(hf_private->is_setup_by_stream)
|
||||
{
|
||||
hs_private->stream_write_tag_effective = true;
|
||||
hs_private->release_lock++;
|
||||
}
|
||||
|
||||
printf("frag write end, stream = %p, hf_private = %p\n", hf_private->session->hc_private->stream, hf_private);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -800,6 +813,7 @@ void hs_ops_suspend(struct tfe_http_session * session)
|
||||
{
|
||||
struct http_session_private * hs_private = to_hs_private(session);
|
||||
hs_private->suspend_tag_user = true;
|
||||
hs_private->release_lock++;
|
||||
}
|
||||
|
||||
void hs_ops_resume(struct tfe_http_session * session)
|
||||
@@ -808,6 +822,7 @@ void hs_ops_resume(struct tfe_http_session * session)
|
||||
struct http_connection_private * hc_private = hs_private->hc_private;
|
||||
|
||||
hs_private->suspend_tag_user = false;
|
||||
hs_private->release_lock--;
|
||||
tfe_stream_resume(hc_private->stream);
|
||||
}
|
||||
|
||||
@@ -1024,10 +1039,11 @@ void hf_private_construct(struct http_half_private * hf_private)
|
||||
return;
|
||||
}
|
||||
|
||||
struct http_session_private * hs_private_create(struct http_connection_private * hc_private,
|
||||
struct http_half_private * hf_private_req, struct http_half_private * hf_private_resp)
|
||||
struct http_session_private * hs_private_create(struct http_connection_private * hc_private, unsigned int thread_id,
|
||||
struct http_half_private * hf_private_req, struct http_half_private * hf_private_resp)
|
||||
{
|
||||
struct http_session_private * __hs_private = ALLOC(struct http_session_private, 1);
|
||||
__hs_private->thread_id = thread_id;
|
||||
|
||||
/* HS-PUBLIC */
|
||||
__hs_private->hs_public.ops = &__http_session_ops;
|
||||
@@ -1085,12 +1101,43 @@ void __write_access_log(struct http_session_private * hs_private)
|
||||
free(__access_log);
|
||||
}
|
||||
|
||||
void hs_private_destory(struct http_session_private * hs_private)
|
||||
void hs_private_destroy(struct http_session_private * hs_private)
|
||||
{
|
||||
struct http_half_private * hf_req = to_hf_request_private(hs_private);
|
||||
struct http_half_private * hf_resp = to_hf_response_private(hs_private);
|
||||
|
||||
__write_access_log(hs_private);
|
||||
|
||||
if (hf_req != NULL)
|
||||
{
|
||||
hf_private_destory(hf_req);
|
||||
}
|
||||
|
||||
if (hf_resp != NULL)
|
||||
{
|
||||
hf_private_destory(hf_resp);
|
||||
}
|
||||
|
||||
if (hs_private->hf_private_req_user)
|
||||
{
|
||||
hf_private_destory(hs_private->hf_private_req_user);
|
||||
}
|
||||
|
||||
if (hs_private->hf_private_resp_user)
|
||||
{
|
||||
hf_private_destory(hs_private->hf_private_resp_user);
|
||||
}
|
||||
|
||||
assert(hs_private->ht_frame == NULL);
|
||||
free(hs_private);
|
||||
}
|
||||
|
||||
void hs_private_gc_destroy(struct http_session_private * hs_private, struct hs_private_list * gc_list)
|
||||
{
|
||||
if (hs_private->release_lock > 0) TAILQ_INSERT_TAIL(gc_list, hs_private, next);
|
||||
else return hs_private_destroy(hs_private);
|
||||
}
|
||||
|
||||
void hs_private_hf_private_set(struct http_session_private * hs_private,
|
||||
struct http_half_private * hf, enum tfe_http_direction direction)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user