MINOR: mux-h1: Add masks to group H1S DEMUX and MUX errors

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.
This commit is contained in:
Christopher Faulet 2024-12-23 11:20:35 +01:00
parent 8235a24782
commit e56e718c82
2 changed files with 8 additions and 5 deletions

View 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 */

View 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: