todo:http 写文件的bug。
This commit is contained in:
@@ -500,7 +500,7 @@ static void __stream_bev_writecb(struct bufferevent * bev, void * arg)
|
||||
struct evbuffer * __output_buffer = bufferevent_get_output(bev);
|
||||
assert(__output_buffer != NULL);
|
||||
|
||||
if (*ref_peer_conn == NULL && evbuffer_get_length(__output_buffer) == 0)
|
||||
if (*ref_peer_conn == NULL && (*ref_this_conn)->on_writing == 0 && evbuffer_get_length(__output_buffer) == 0)
|
||||
{
|
||||
__conn_private_destory_with_ssl(ev_base, *ref_this_conn, *ref_this_ssl_stream);
|
||||
*ref_this_conn = NULL;
|
||||
@@ -529,12 +529,14 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
|
||||
struct ssl_stream ** ref_this_ssl_stream{};
|
||||
struct ssl_stream ** ref_peer_ssl_stream{};
|
||||
|
||||
const char * __str_dir = NULL;
|
||||
if (__bev_dir(_stream, bev) == CONN_DIR_UPSTREAM)
|
||||
{
|
||||
ref_this_conn = &_stream->conn_upstream;
|
||||
ref_peer_conn = &_stream->conn_downstream;
|
||||
ref_this_ssl_stream = &_stream->ssl_upstream;
|
||||
ref_peer_ssl_stream = &_stream->ssl_downstream;
|
||||
__str_dir = "up";
|
||||
}
|
||||
|
||||
if (__bev_dir(_stream, bev) == CONN_DIR_DOWNSTREAM)
|
||||
@@ -543,6 +545,7 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
|
||||
ref_peer_conn = &_stream->conn_upstream;
|
||||
ref_this_ssl_stream = &_stream->ssl_downstream;
|
||||
ref_peer_ssl_stream = &_stream->ssl_upstream;
|
||||
__str_dir = "down";
|
||||
}
|
||||
|
||||
if (events & BEV_EVENT_ERROR || events & BEV_EVENT_EOF)
|
||||
@@ -552,6 +555,7 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
|
||||
__stream_bev_readcb(bev, arg);
|
||||
}
|
||||
|
||||
fprintf(stderr, "---- eventcb ----, stream = %p, event = %x, dir = %s\n", _stream, events, __str_dir);
|
||||
goto __close_connection;
|
||||
}
|
||||
|
||||
@@ -563,7 +567,7 @@ __close_connection:
|
||||
struct bufferevent * __peer_bev = (*ref_peer_conn)->bev;
|
||||
struct evbuffer * __peer_output_buffer = bufferevent_get_output(__peer_bev);
|
||||
|
||||
if (evbuffer_get_length(__peer_output_buffer) == 0)
|
||||
if (evbuffer_get_length(__peer_output_buffer) == 0 && (*ref_peer_conn)->on_writing == 0)
|
||||
{
|
||||
__conn_private_destory_with_ssl(ev_base, *ref_peer_conn, *ref_peer_ssl_stream);
|
||||
*ref_peer_conn = NULL;
|
||||
@@ -573,6 +577,9 @@ __close_connection:
|
||||
|
||||
if (*ref_this_conn != NULL)
|
||||
{
|
||||
fprintf(stderr, "---- eventcb ----, close this connection, stream = %p, event = %x, dir = %s\n", _stream, events, __str_dir);
|
||||
|
||||
assert((*ref_this_conn)->on_writing == 0);
|
||||
__conn_private_destory_with_ssl(ev_base, *ref_this_conn, *ref_this_ssl_stream);
|
||||
*ref_this_conn = NULL;
|
||||
*ref_this_ssl_stream = NULL;
|
||||
|
||||
@@ -207,7 +207,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
|
||||
cJSON_AddStringToObject(common_obj,req_fields[i].log_filed_name, tmp_val);
|
||||
}
|
||||
}
|
||||
for(size_t i=0;i<sizeof(resp_fields)/sizeof(struct json_spec);i++)
|
||||
for(size_t i=0;i<sizeof(resp_fields)/sizeof(struct json_spec) && http->resp!=NULL;i++)
|
||||
{
|
||||
tmp_val=tfe_http_std_field_read(http->resp, resp_fields[i].field_id);
|
||||
if(tmp_val!=NULL)
|
||||
|
||||
@@ -171,7 +171,8 @@ int __on_request_handle_user_req_or_resp(const tfe_stream * stream, struct http_
|
||||
TAILQ_INSERT_TAIL(&hc_private->hs_private_orphan_list, hs_private, next);
|
||||
}
|
||||
|
||||
assert(hf_private_req_in->stream_action == ACTION_DEFER_DATA);
|
||||
assert(hf_private_req_in->stream_action == ACTION_DEFER_DATA
|
||||
|| hf_private_req_in->stream_action == ACTION_DROP_DATA);
|
||||
hf_private_req_in->stream_action = ACTION_DROP_DATA;
|
||||
}
|
||||
|
||||
|
||||
@@ -838,19 +838,30 @@ void hs_ops_response_set(struct tfe_http_session * session, struct tfe_http_half
|
||||
{
|
||||
struct http_half_private * hf_private = to_hf_private(resp);
|
||||
struct http_session_private * hs_private = to_hs_private(session);
|
||||
struct http_half_private * hf_in_private = to_hf_response_private(hs_private);
|
||||
struct http_half_private * hf_in_req_private = to_hf_request_private(hs_private);
|
||||
struct http_half_private * hf_in_resp_private = to_hf_response_private(hs_private);
|
||||
|
||||
if (hf_in_private != NULL)
|
||||
/* Call at request's callback, early response */
|
||||
if(hf_in_req_private != NULL && hf_in_resp_private == NULL)
|
||||
{
|
||||
if (hf_in_private->stream_action == ACTION_DEFER_DATA)
|
||||
/* Drop the incoming request */
|
||||
if (hf_in_req_private->stream_action == ACTION_DEFER_DATA)
|
||||
{
|
||||
hf_in_private->user_stream_action = ACTION_DROP_DATA;
|
||||
hf_in_private->is_user_stream_action_set = true;
|
||||
hf_in_req_private->user_stream_action = ACTION_DROP_DATA;
|
||||
hf_in_req_private->is_user_stream_action_set = true;
|
||||
}
|
||||
else
|
||||
else assert(0);
|
||||
}
|
||||
|
||||
/* Call at response's callback, replace incoming response */
|
||||
if (hf_in_req_private != NULL && hf_in_resp_private != NULL)
|
||||
{
|
||||
if (hf_in_resp_private->stream_action == ACTION_DEFER_DATA)
|
||||
{
|
||||
assert(0);
|
||||
hf_in_resp_private->user_stream_action = ACTION_DROP_DATA;
|
||||
hf_in_resp_private->is_user_stream_action_set = true;
|
||||
}
|
||||
else assert(0);
|
||||
}
|
||||
|
||||
assert(hs_private->hf_private_resp_user == NULL);
|
||||
|
||||
Reference in New Issue
Block a user