4141#include "nghttp2_debug.h"
4242#include "nghttp2_submit.h"
4343
44- nghttp2_stream root ;
44+ nghttp2_stream nghttp2_stream_root ;
4545
4646/*
4747 * Returns non-zero if the number of outgoing opened streams is larger
@@ -1092,6 +1092,15 @@ int nghttp2_session_add_item(nghttp2_session *session,
10921092
10931093int nghttp2_session_add_rst_stream (nghttp2_session * session , int32_t stream_id ,
10941094 uint32_t error_code ) {
1095+ return nghttp2_session_add_rst_stream_continue (
1096+ session , stream_id , error_code ,
1097+ /* continue_without_stream = */ 1 );
1098+ }
1099+
1100+ int nghttp2_session_add_rst_stream_continue (nghttp2_session * session ,
1101+ int32_t stream_id ,
1102+ uint32_t error_code ,
1103+ int continue_without_stream ) {
10951104 int rv ;
10961105 nghttp2_outbound_item * item ;
10971106 nghttp2_frame * frame ;
@@ -1148,6 +1157,12 @@ int nghttp2_session_add_rst_stream(nghttp2_session *session, int32_t stream_id,
11481157 }
11491158 }
11501159
1160+ /* To keep the old behaviour, do not fail if stream was not
1161+ found. */
1162+ if (!continue_without_stream && !stream ) {
1163+ return 0 ;
1164+ }
1165+
11511166 item = nghttp2_mem_malloc (mem , sizeof (nghttp2_outbound_item ));
11521167 if (item == NULL ) {
11531168 return NGHTTP2_ERR_NOMEM ;
@@ -7715,7 +7730,7 @@ int32_t nghttp2_session_get_last_proc_stream_id(nghttp2_session *session) {
77157730nghttp2_stream * nghttp2_session_find_stream (nghttp2_session * session ,
77167731 int32_t stream_id ) {
77177732 if (stream_id == 0 ) {
7718- return & root ;
7733+ return & nghttp2_stream_root ;
77197734 }
77207735
77217736 return nghttp2_session_get_stream_raw (session , stream_id );
@@ -7724,7 +7739,7 @@ nghttp2_stream *nghttp2_session_find_stream(nghttp2_session *session,
77247739nghttp2_stream * nghttp2_session_get_root_stream (nghttp2_session * session ) {
77257740 (void )session ;
77267741
7727- return & root ;
7742+ return & nghttp2_stream_root ;
77287743}
77297744
77307745int nghttp2_session_check_server_session (nghttp2_session * session ) {
0 commit comments