修复HTTP2多次刷新导致请求数据提前释放资源

This commit is contained in:
fengweihao
2020-11-20 13:54:07 +08:00
parent 3a63d22256
commit 47a572bda3

View File

@@ -1948,15 +1948,20 @@ nghttp2_on_stream_close(nghttp2_session *session, const nghttp2_frame *frame, co
goto end;
}
finish:
TAILQ_REMOVE(&h2_stream_info->h2_session_list, h2_session, next);
if (h2_session->frame_ctx){
http_frame_raise_session_end(h2_session->frame_ctx, h2_session->tf_stream, &h2_session->tfe_session,
h2_stream_info->thread_id);
h2_session->frame_ctx = NULL;
if((dir == CONN_DIR_DOWNSTREAM && (h2_session->resp == NULL || h2_session->plugin_built_resp != NULL) )|| dir == CONN_DIR_UPSTREAM)
{
TAILQ_REMOVE(&h2_stream_info->h2_session_list, h2_session, next);
}
if ((dir == CONN_DIR_DOWNSTREAM && h2_session->frame_ctx && h2_session->plugin_built_resp != NULL)
||(dir == CONN_DIR_UPSTREAM && h2_session->frame_ctx))
{
http_frame_raise_session_end(h2_session->frame_ctx, h2_session->tf_stream, &h2_session->tfe_session,
h2_stream_info->thread_id);
h2_session->frame_ctx = NULL;
delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1);
free(h2_session);
h2_session = NULL;
}
delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1);
free(h2_session);
h2_session = NULL;
end:
return 0;
}
@@ -2044,7 +2049,7 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
/*proc build resp*/
/*when input_len == 1 is end_stream, Nghttp2 sends this frame, drop it*/
struct tfe_h2_session *h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(session, stream_id);
if (h2_session == NULL )
if (h2_session == NULL || (flags !=0 && input_len == 1))
{
return 0;
}