]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) mod_http2: when using a pipe for input signalling, always
authorStefan Eissing <icing@apache.org>
Mon, 21 Mar 2022 10:38:05 +0000 (10:38 +0000)
committerStefan Eissing <icing@apache.org>
Mon, 21 Mar 2022 10:38:05 +0000 (10:38 +0000)
     write to it on sending buckets, not only when it was empty.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899108 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_bucket_beam.c
modules/http2/h2_bucket_beam.h
modules/http2/h2_mplx.c

index c0968b6d9307bdfd16aaea8087535f0fe7d5f787..6ac85a5e9582f0b1239d81687fce76a167216e58 100644 (file)
@@ -387,6 +387,9 @@ void h2_beam_abort(h2_bucket_beam *beam, conn_rec *c)
     beam->aborted = 1;
     if (c == beam->from) {
         /* sender aborts */
+        if (beam->send_cb) {
+            beam->send_cb(beam->send_ctx, beam);
+        }
         if (beam->was_empty_cb && buffer_is_empty(beam)) {
             beam->was_empty_cb(beam->was_empty_ctx, beam);
         }
@@ -542,6 +545,9 @@ apr_status_t h2_beam_send(h2_bucket_beam *beam, conn_rec *from,
              * Trigger event callbacks, so receiver can know there is something
              * to receive before we do a conditional wait. */
             purge_consumed_buckets(beam);
+            if (beam->send_cb) {
+                beam->send_cb(beam->send_ctx, beam);
+            }
             if (was_empty && beam->was_empty_cb) {
                 beam->was_empty_cb(beam->was_empty_ctx, beam);
             }
@@ -553,6 +559,9 @@ apr_status_t h2_beam_send(h2_bucket_beam *beam, conn_rec *from,
         }
     }
 
+    if (beam->send_cb && !buffer_is_empty(beam)) {
+        beam->send_cb(beam->send_ctx, beam);
+    }
     if (was_empty && beam->was_empty_cb && !buffer_is_empty(beam)) {
         beam->was_empty_cb(beam->was_empty_ctx, beam);
     }
@@ -760,6 +769,15 @@ void h2_beam_on_received(h2_bucket_beam *beam,
     apr_thread_mutex_unlock(beam->lock);
 }
 
+void h2_beam_on_send(h2_bucket_beam *beam,
+                     h2_beam_ev_callback *send_cb, void *ctx)
+{
+    apr_thread_mutex_lock(beam->lock);
+    beam->send_cb = send_cb;
+    beam->send_ctx = ctx;
+    apr_thread_mutex_unlock(beam->lock);
+}
+
 void h2_beam_on_was_empty(h2_bucket_beam *beam,
                           h2_beam_ev_callback *was_empty_cb, void *ctx)
 {
index b6847733e36d2ac4eb783a2c8745e5111368ff8c..dced250dba7891494c0a64f19149707411317ed3 100644 (file)
@@ -65,6 +65,8 @@ struct h2_bucket_beam {
     void *was_empty_ctx;
     h2_beam_ev_callback *recv_cb;      /* event: buckets were transfered in h2_beam_receive() */
     void *recv_ctx;
+    h2_beam_ev_callback *send_cb;      /* event: buckets were added in h2_beam_send() */
+    void *send_ctx;
 
     apr_off_t recv_bytes;             /* amount of bytes transferred in h2_beam_receive() */
     apr_off_t recv_bytes_reported;    /* amount of bytes reported as received via callback */
@@ -195,6 +197,17 @@ void h2_beam_on_consumed(h2_bucket_beam *beam,
 void h2_beam_on_received(h2_bucket_beam *beam,
                          h2_beam_ev_callback *recv_cb, void *ctx);
 
+/**
+ * Register a call back from the sender side to be invoked when send
+ * has added buckets to the beam.
+ * Unregister by passing a NULL on_send_cb.
+ * @param beam the beam to set the callback on
+ * @param on_send_cb the callback to invoke after buckets were added
+ * @param ctx  the context to use in callback invocation
+ */
+void h2_beam_on_send(h2_bucket_beam *beam,
+                     h2_beam_ev_callback *on_send_cb, void *ctx);
+
 /**
  * Register a call back from the sender side to be invoked when send
  * has added to a previously empty beam.
index 1f1b31d24003321c7f4c9bc4a35fcf49ecc7a95a..28315d76a63b487d10d2d4a9deea9a9bb888de3f 100644 (file)
@@ -139,6 +139,7 @@ static void m_stream_cleanup(h2_mplx *m, h2_stream *stream)
             h2_beam_on_was_empty(c2_ctx->beam_out, NULL, NULL);
         }
         if (c2_ctx->beam_in) {
+            h2_beam_on_send(c2_ctx->beam_in, NULL, NULL);
             h2_beam_on_received(c2_ctx->beam_in, NULL, NULL);
             h2_beam_on_consumed(c2_ctx->beam_in, NULL, NULL);
         }
@@ -796,7 +797,7 @@ static apr_status_t c2_setup_io(h2_mplx *m, conn_rec *c2, h2_stream *stream, h2_
 
     if (stream->input) {
         conn_ctx->beam_in = stream->input;
-        h2_beam_on_was_empty(stream->input, c2_beam_input_write_notify, c2);
+        h2_beam_on_send(stream->input, c2_beam_input_write_notify, c2);
         h2_beam_on_received(stream->input, c2_beam_input_read_notify, c2);
         h2_beam_on_consumed(stream->input, c1_input_consumed, stream);
     }