]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Add masks to group H1S DEMUX and MUX errors
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Dec 2024 10:20:35 +0000 (11:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 31 Jan 2025 09:41:49 +0000 (10:41 +0100)
It is just a small patch to clean up mux/demux functions. Instead of listing
the H1S errors that must be handled during demux of mux operations, masks of
flags are used. It is more readable.

include/haproxy/mux_h1-t.h
src/mux_h1.c

index e0c29c25e2ff6aaf7bf2fe00aaf7fa52a715ff48..a886d364c4bd9766844f1a7c5819b06fbf8586d5 100644 (file)
@@ -100,6 +100,9 @@ static forceinline char *h1c_show_flags(char *buf, size_t len, const char *delim
 #define H1S_F_PARSING_ERROR  0x00000800 /* Set when an error occurred during the message parsing */
 #define H1S_F_PROCESSING_ERROR 0x00001000 /* Set when an error occurred during the message xfer */
 
+#define H1S_F_DEMUX_ERROR (H1S_F_INTERNAL_ERROR|H1S_F_NOT_IMPL_ERROR|H1S_F_PARSING_ERROR)
+#define H1S_F_MUX_ERROR   (H1S_F_INTERNAL_ERROR|H1S_F_PROCESSING_ERROR)
+
 #define H1S_F_HAVE_SRV_NAME  0x00002000 /* Set during output process if the server name header was added to the request */
 #define H1S_F_HAVE_O_CONN    0x00004000 /* Set during output process to know connection mode was processed */
 #define H1S_F_HAVE_WS_KEY    0x00008000 /* Set during output process to know WS key was found or generated */
index f30ea3742542cf92f852f0848086c0e380767596..9c64d8fb7a3ef5bbe07efd7ebaa8517a612bafbb 100644 (file)
@@ -2109,7 +2109,7 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
        h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->req : &h1s->res);
        data = htx->data;
 
-       if (h1s->flags & (H1S_F_INTERNAL_ERROR|H1S_F_PARSING_ERROR|H1S_F_NOT_IMPL_ERROR))
+       if (h1s->flags & H1S_F_DEMUX_ERROR)
                goto end;
 
        if (h1s->flags & H1S_F_RX_BLK)
@@ -2206,10 +2206,10 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
                }
 
                count -= htx_used_space(htx) - used;
-       } while (!(h1s->flags & (H1S_F_PARSING_ERROR|H1S_F_NOT_IMPL_ERROR|H1S_F_RX_BLK|H1S_F_RX_CONGESTED)));
+       } while (!(h1s->flags & (H1S_F_DEMUX_ERROR|H1S_F_RX_BLK|H1S_F_RX_CONGESTED)));
 
 
-       if (h1s->flags & (H1S_F_PARSING_ERROR|H1S_F_NOT_IMPL_ERROR)) {
+       if (h1s->flags & H1S_F_DEMUX_ERROR) {
                TRACE_ERROR("parsing or not-implemented error", H1_EV_RX_DATA|H1_EV_H1S_ERR, h1c->conn, h1s);
                goto err;
        }
@@ -3442,7 +3442,7 @@ static size_t h1_process_mux(struct h1c *h1c, struct buffer *buf, size_t count)
        if (htx_is_empty(htx))
                goto end;
 
-       if (h1s->flags & (H1S_F_INTERNAL_ERROR|H1S_F_PROCESSING_ERROR|H1S_F_TX_BLK))
+       if (h1s->flags & (H1S_F_MUX_ERROR|H1S_F_TX_BLK))
                goto end;
 
        if (!h1_get_obuf(h1c)) {
@@ -3452,7 +3452,7 @@ static size_t h1_process_mux(struct h1c *h1c, struct buffer *buf, size_t count)
        h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->res : &h1s->req);
 
        while (!(h1c->flags & H1C_F_OUT_FULL) &&
-              !(h1s->flags & (H1S_F_PROCESSING_ERROR|H1S_F_TX_BLK)) &&
+              !(h1s->flags & (H1S_F_MUX_ERROR|H1S_F_TX_BLK)) &&
               !htx_is_empty(htx) && count) {
                switch (h1m->state) {
                        case H1_MSG_RQBEFORE: