You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2021/04/18 18:55:43 UTC

svn commit: r1888922 - in /httpd/httpd/branches/2.4.x: ./ changes-entries/h2_close_race.txt modules/http2/h2_bucket_beam.c modules/http2/h2_bucket_beam.h modules/http2/h2_stream.c modules/http2/h2_task.c

Author: jailletc36
Date: Sun Apr 18 18:55:43 2021
New Revision: 1888922

URL: http://svn.apache.org/viewvc?rev=1888922&view=rev
Log:
Merge r1888087 from trunk

   * mod_http2: Fixed a race condition that could lead to streams being
     aborted (RST to the client), although a response had been produced

Submitted by: icing
Reviewed by: icing, rpluem, covener
Backported by: jailletc36

Added:
    httpd/httpd/branches/2.4.x/changes-entries/h2_close_race.txt
      - copied unchanged from r1888087, httpd/httpd/trunk/changes-entries/h2_close_race.txt
Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.c
    httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.h
    httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c
    httpd/httpd/branches/2.4.x/modules/http2/h2_task.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1888087

Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.c?rev=1888922&r1=1888921&r2=1888922&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.c Sun Apr 18 18:55:43 2021
@@ -945,7 +945,8 @@ apr_status_t h2_beam_send(h2_bucket_beam
 apr_status_t h2_beam_receive(h2_bucket_beam *beam, 
                              apr_bucket_brigade *bb, 
                              apr_read_type_e block,
-                             apr_off_t readbytes)
+                             apr_off_t readbytes,
+                             int *pclosed)
 {
     h2_beam_lock bl;
     apr_bucket *bsender, *brecv, *ng;
@@ -953,7 +954,7 @@ apr_status_t h2_beam_receive(h2_bucket_b
     apr_status_t status = APR_SUCCESS;
     apr_off_t remain;
     int transferred_buckets = 0;
-    
+
     /* Called from the receiver thread to take buckets from the beam */
     if (enter_yellow(beam, &bl) == APR_SUCCESS) {
         if (readbytes <= 0) {
@@ -1127,7 +1128,8 @@ transfer:
             }
             goto transfer;
         }
-leave:        
+leave:
+        if (pclosed) *pclosed = beam->closed? 1 : 0;
         leave_yellow(beam, &bl);
     }
     return status;

Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.h?rev=1888922&r1=1888921&r2=1888922&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.h (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_bucket_beam.h Sun Apr 18 18:55:43 2021
@@ -258,11 +258,15 @@ void h2_beam_send_from(h2_bucket_beam *b
  * if no data is available.
  *
  * Call from the receiver side only.
+ * @param pclosed  on return != 0 iff the beam has been closed by the sender. It
+ *                 may still hold untransfered data. Maybe NULL if the caller is
+ *                 not interested in this.
  */
 apr_status_t h2_beam_receive(h2_bucket_beam *beam, 
                              apr_bucket_brigade *green_buckets, 
                              apr_read_type_e block,
-                             apr_off_t readbytes);
+                             apr_off_t readbytes,
+                             int *pclosed);
 
 /**
  * Determine if beam is empty. 

Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c?rev=1888922&r1=1888921&r2=1888922&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_stream.c Sun Apr 18 18:55:43 2021
@@ -901,7 +901,7 @@ apr_status_t h2_stream_out_prepare(h2_st
     apr_status_t status = APR_SUCCESS;
     apr_off_t requested, missing, max_chunk = H2_DATA_CHUNK_SIZE;
     conn_rec *c;
-    int complete;
+    int complete, was_closed = 0;
 
     ap_assert(stream);
     
@@ -950,9 +950,11 @@ apr_status_t h2_stream_out_prepare(h2_st
         
         if (stream->output) {
             H2_STREAM_OUT_LOG(APLOG_TRACE2, stream, "pre");
-            rv = h2_beam_receive(stream->output, stream->out_buffer, 
-                                 APR_NONBLOCK_READ, stream->max_mem - *plen);
+            h2_beam_log(stream->output, c, APLOG_TRACE2, "pre read output");
+            rv = h2_beam_receive(stream->output, stream->out_buffer,
+                                 APR_NONBLOCK_READ, stream->max_mem - *plen, &was_closed);
             H2_STREAM_OUT_LOG(APLOG_TRACE2, stream, "post");
+            h2_beam_log(stream->output, c, APLOG_TRACE2, "post read output");
         }
         
         if (rv == APR_SUCCESS) {
@@ -982,7 +984,7 @@ apr_status_t h2_stream_out_prepare(h2_st
                           (long)*plen, *peos);
         }
         else {
-            status = (stream->output && h2_beam_is_closed(stream->output))? APR_EOF : APR_EAGAIN;
+            status = was_closed? APR_EOF : APR_EAGAIN;
             ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
                           H2_STRM_MSG(stream, "prepare, no data"));
         }

Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_task.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_task.c?rev=1888922&r1=1888921&r2=1888922&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_task.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_task.c Sun Apr 18 18:55:43 2021
@@ -266,7 +266,7 @@ static apr_status_t h2_filter_secondary_
         }
         if (task->input.beam) {
             status = h2_beam_receive(task->input.beam, task->input.bb, block, 
-                                     128*1024);
+                                     128*1024, NULL);
         }
         else {
             status = APR_EOF;