@@ -99,7 +99,7 @@ static int rst_unprocessed_stream(h2_stream *stream, void *ctx)
9999 (!stream -> session -> remote .accepting
100100 && stream -> id > stream -> session -> remote .accepted_max ))
101101 );
102- if (unprocessed ) {
102+ if (unprocessed && stream -> state < H2_SS_CLEANUP ) {
103103 h2_stream_rst (stream , H2_ERR_NO_ERROR );
104104 return 0 ;
105105 }
@@ -269,7 +269,7 @@ static int on_stream_close_cb(nghttp2_session *ngh2, int32_t stream_id,
269269
270270 (void )ngh2 ;
271271 stream = get_stream (session , stream_id );
272- if (stream ) {
272+ if (stream && stream -> state < H2_SS_CLEANUP ) {
273273 if (error_code ) {
274274 ap_log_cerror (APLOG_MARK , APLOG_DEBUG , 0 , session -> c1 ,
275275 H2_STRM_LOG (APLOGNO (03065 ), stream ,
@@ -512,6 +512,7 @@ static int on_send_data_cb(nghttp2_session *ngh2,
512512 h2_stream * stream ;
513513 apr_bucket * b ;
514514 apr_off_t len = length ;
515+ apr_bucket_brigade * bb ;
515516
516517 (void )ngh2 ;
517518 (void )source ;
@@ -542,29 +543,31 @@ static int on_send_data_cb(nghttp2_session *ngh2,
542543 return NGHTTP2_ERR_CALLBACK_FAILURE ;
543544 }
544545
545- status = h2_stream_read_to (stream , session -> bbtmp , & len , & eos );
546+ bb = apr_brigade_create (session -> pool ,
547+ session -> c1 -> bucket_alloc );
548+ status = h2_stream_read_to (stream , bb , & len , & eos );
546549 if (status != APR_SUCCESS ) {
547550 ap_log_cerror (APLOG_MARK , APLOG_TRACE1 , status , session -> c1 ,
548551 H2_STRM_MSG (stream , "send_data_cb, reading stream" ));
549- apr_brigade_cleanup ( session -> bbtmp );
552+ apr_brigade_destroy ( bb );
550553 return NGHTTP2_ERR_CALLBACK_FAILURE ;
551554 }
552555 else if (len != (apr_off_t )length ) {
553556 ap_log_cerror (APLOG_MARK , APLOG_TRACE1 , status , session -> c1 ,
554557 H2_STRM_MSG (stream , "send_data_cb, wanted %ld bytes, "
555558 "got %ld from stream" ), (long )length , (long )len );
556- apr_brigade_cleanup ( session -> bbtmp );
559+ apr_brigade_destroy ( bb );
557560 return NGHTTP2_ERR_CALLBACK_FAILURE ;
558561 }
559-
562+
560563 if (padlen ) {
561- b = apr_bucket_immortal_create (immortal_zeros , padlen ,
564+ b = apr_bucket_immortal_create (immortal_zeros , padlen ,
562565 session -> c1 -> bucket_alloc );
563- APR_BRIGADE_INSERT_TAIL (session -> bbtmp , b );
566+ APR_BRIGADE_INSERT_TAIL (bb , b );
564567 }
565-
566- status = h2_c1_io_append (& session -> io , session -> bbtmp );
567- apr_brigade_cleanup ( session -> bbtmp );
568+
569+ status = h2_c1_io_append (& session -> io , bb );
570+ apr_brigade_destroy ( bb );
568571
569572 if (status == APR_SUCCESS ) {
570573 stream -> out_data_frames ++ ;
@@ -1708,6 +1711,7 @@ static void ev_stream_open(h2_session *session, h2_stream *stream)
17081711static void ev_stream_closed (h2_session * session , h2_stream * stream )
17091712{
17101713 apr_bucket * b ;
1714+ apr_bucket_brigade * bb ;
17111715
17121716 if (H2_STREAM_CLIENT_INITIATED (stream -> id )
17131717 && (stream -> id > session -> local .completed_max )) {
@@ -1721,9 +1725,11 @@ static void ev_stream_closed(h2_session *session, h2_stream *stream)
17211725 ap_log_cerror (APLOG_MARK , APLOG_TRACE2 , 0 , session -> c1 ,
17221726 H2_STRM_MSG (stream , "adding h2_eos to c1 out" ));
17231727 b = h2_bucket_eos_create (session -> c1 -> bucket_alloc , stream );
1724- APR_BRIGADE_INSERT_TAIL (session -> bbtmp , b );
1725- h2_c1_io_append (& session -> io , session -> bbtmp );
1726- apr_brigade_cleanup (session -> bbtmp );
1728+ bb = apr_brigade_create (session -> pool ,
1729+ session -> c1 -> bucket_alloc );
1730+ APR_BRIGADE_INSERT_TAIL (bb , b );
1731+ h2_c1_io_append (& session -> io , bb );
1732+ apr_brigade_destroy (bb );
17271733}
17281734
17291735static void on_stream_state_enter (void * ctx , h2_stream * stream )
@@ -1761,10 +1767,12 @@ static void on_stream_state_enter(void *ctx, h2_stream *stream)
17611767 break ;
17621768 case H2_SS_CLEANUP :
17631769 nghttp2_session_set_stream_user_data (session -> ngh2 , stream -> id , NULL );
1764- update_child_status (session , SERVER_BUSY_WRITE , "done" , stream );
1765- h2_mplx_c1_stream_cleanup (session -> mplx , stream , & session -> open_streams );
1766- stream = NULL ;
1767- ++ session -> streams_done ;
1770+ if (!session -> mplx -> in_stream_cleanup ) {
1771+ update_child_status (session , SERVER_BUSY_WRITE , "done" , stream );
1772+ h2_mplx_c1_stream_cleanup (session -> mplx , stream , & session -> open_streams );
1773+ stream = NULL ;
1774+ ++ session -> streams_done ;
1775+ }
17681776 break ;
17691777 default :
17701778 break ;
0 commit comments