diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp index c63c5ff..fc404f2 100644 --- a/plugin/protocol/http2/src/http2_stream.cpp +++ b/plugin/protocol/http2/src/http2_stream.cpp @@ -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; }