]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: remove dedicated function to handle standalone FIN
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 11 May 2023 14:49:28 +0000 (16:49 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 May 2023 13:50:30 +0000 (15:50 +0200)
Remove QUIC MUX function qcs_http_handle_standalone_fin(). The purpose
of this function was only used when receiving an empty STREAM frame with
FIN bit. Besides, it was called by each application protocol which could
have different approach and render the function purpose unclear.

Invocation of qcs_http_handle_standalone_fin() have been replaced by
explicit code in both H3 and HTTP/0.9 module. In the process, use
htx_set_eom() to reliably put EOM on the HTX message.

This should be backported up to 2.7, along with the previous patch which
introduced htx_set_eom().

include/haproxy/qmux_http.h
src/h3.c
src/hq_interop.c
src/qmux_http.c

index 98151db16711d578161de8d7278f911c0c03ee4d..a7dbe7cc329ad79d06505b5e285ef513cc4b271a 100644 (file)
@@ -12,8 +12,6 @@ size_t qcs_http_snd_buf(struct qcs *qcs, struct buffer *buf, size_t count,
                         char *fin);
 size_t qcs_http_reset_buf(struct qcs *qcs, struct buffer *buf, size_t count);
 
-void qcs_http_handle_standalone_fin(struct qcs *qcs);
-
 #endif /* USE_QUIC */
 
 #endif /* _HAPROXY_MUX_QUIC_HTTP_H */
index e686f0de0054caf7b641a172f58a5f42af3cadb6..d41a20c21df5398f0453fd6dd854d29fb6d9c89b 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1036,8 +1036,19 @@ static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
        }
 
        if (!b_data(b) && fin && quic_stream_is_bidi(qcs->id)) {
+               struct buffer *appbuf;
+               struct htx *htx;
+
                TRACE_PROTO("received FIN without data", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
-               qcs_http_handle_standalone_fin(qcs);
+               appbuf = qc_get_buf(qcs, &qcs->rx.app_buf);
+               BUG_ON(!appbuf);
+
+               htx = htx_from_buf(appbuf);
+               if (!htx_set_eom(htx)) {
+                       TRACE_ERROR("cannot set EOM", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
+                       h3c->err = H3_INTERNAL_ERROR;
+               }
+               htx_to_buf(htx, appbuf);
                goto done;
        }
 
index 175b92decfd6d4d3b15115594f0ed89d76532178..cbbf47288a71450b2d413b4c92a00615158770be 100644 (file)
@@ -21,9 +21,20 @@ static ssize_t hq_interop_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
        size_t data = b_data(b);
 
        if (!data && fin) {
+               struct buffer *appbuf;
+               struct htx *htx;
+
                /* FIN is notified with an empty STREAM frame. */
                BUG_ON(!qcs->sd); /* sd must already be attached here */
-               qcs_http_handle_standalone_fin(qcs);
+
+               if (!(appbuf = qc_get_buf(qcs, &qcs->rx.app_buf)))
+                       return -1;
+
+               htx = htx_from_buf(appbuf);
+               if (!htx_set_eom(htx))
+                       return -1;
+               htx_to_buf(htx, appbuf);
+
                return 0;
        }
 
index 73b00389cb1a62a78708a299aa7b59242dc3921c..fc891dc53ade050699a4a6c3006dc507292c96ae 100644 (file)
@@ -110,25 +110,3 @@ size_t qcs_http_reset_buf(struct qcs *qcs, struct buffer *buf, size_t count)
 
        return count;
 }
-
-/* Utility function which can be used by app layer an empty STREAM frame is
- * received with FIN bit set for <qcs> stream. It will ensure that HTX EOM is
- * properly inserted in <qcs> app_buf.
- */
-void qcs_http_handle_standalone_fin(struct qcs *qcs)
-{
-       struct buffer *appbuf;
-       struct htx *htx = NULL;
-
-       appbuf = qc_get_buf(qcs, &qcs->rx.app_buf);
-       BUG_ON(!appbuf);
-
-       htx = htx_from_buf(appbuf);
-       if (htx_is_empty(htx)) {
-               if (!htx_add_endof(htx, HTX_BLK_EOT)) {
-                       ABORT_NOW(); /* cannot happen for empty HTX message. */
-               }
-       }
-       htx->flags |= HTX_FL_EOM;
-       htx_to_buf(htx, appbuf);
-}