]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn_stream: make cs_set_error() work on the endpoint instead
authorWilly Tarreau <w@1wt.eu>
Tue, 10 May 2022 06:46:07 +0000 (08:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 May 2022 12:27:57 +0000 (14:27 +0200)
Wherever we need to report an error, we have an even easier access to
the endpoint than the conn_stream. Let's first adjust the API to use
the endpoint and rename the function accordingly to cs_ep_set_error().

include/haproxy/conn_stream.h
src/mux_fcgi.c
src/mux_h2.c

index 2d5cc4ffa42a5370c85acd1b4e172cbca96bc8e5..ae2d9f0b942200422707ac05fa9374a25dad650d 100644 (file)
@@ -205,13 +205,13 @@ static inline void cs_conn_drain_and_shut(struct conn_stream *cs)
        cs_conn_shutr(cs, CO_SHR_DRAIN);
 }
 
-/* sets CS_EP_ERROR or CS_EP_ERR_PENDING on the cs */
-static inline void cs_set_error(struct conn_stream *cs)
+/* sets CS_EP_ERROR or CS_EP_ERR_PENDING on the endpoint */
+static inline void cs_ep_set_error(struct cs_endpoint *endp)
 {
-       if (cs->endp->flags & CS_EP_EOS)
-               cs->endp->flags |= CS_EP_ERROR;
+       if (endp->flags & CS_EP_EOS)
+               endp->flags |= CS_EP_ERROR;
        else
-               cs->endp->flags |= CS_EP_ERR_PENDING;
+               endp->flags |= CS_EP_ERR_PENDING;
 }
 
 /* Retrieves any valid conn_stream from this connection, preferably the first
index 087e42b2f30cf8bf24129df75de3d59d336cb258..ce392c96271d2993c00312ec927dd67a7fc4f8ef 100644 (file)
@@ -917,7 +917,7 @@ static inline void fcgi_strm_error(struct fcgi_strm *fstrm)
                        TRACE_STATE("switching to ERROR", FCGI_EV_FSTRM_ERR, fstrm->fconn->conn, fstrm);
                }
                if (fstrm->cs)
-                       cs_set_error(fstrm->cs);
+                       cs_ep_set_error(fstrm->cs->endp);
        }
 }
 
@@ -4113,7 +4113,7 @@ static size_t fcgi_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t co
 
        if (fstrm->state == FCGI_SS_ERROR) {
                TRACE_DEVEL("reporting error to the app-layer stream", FCGI_EV_STRM_SEND|FCGI_EV_FSTRM_ERR|FCGI_EV_STRM_ERR, fconn->conn, fstrm);
-               cs_set_error(cs);
+               cs_ep_set_error(cs->endp);
                if (!(fstrm->flags & FCGI_SF_BEGIN_SENT) || fcgi_strm_send_abort(fconn, fstrm))
                        fcgi_strm_close(fstrm);
        }
index b13ac8a97e254b835897e0ecf004cc44ab198271..5e56177596fc11d3f395fc888f03bd3ab79a20e9 100644 (file)
@@ -1274,7 +1274,7 @@ static inline __maybe_unused void h2s_error(struct h2s *h2s, enum h2_err err)
                if (h2s->st < H2_SS_ERROR)
                        h2s->st = H2_SS_ERROR;
                if (h2s->cs)
-                       cs_set_error(h2s->cs);
+                       cs_ep_set_error(h2s->endp);
        }
 }
 
@@ -2749,7 +2749,7 @@ static int h2c_handle_rst_stream(struct h2c *h2c, struct h2s *h2s)
        h2s_close(h2s);
 
        if (h2s->cs) {
-               cs_set_error(h2s->cs);
+               cs_ep_set_error(h2s->endp);
                h2s_alert(h2s);
        }
 
@@ -6662,7 +6662,7 @@ static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
        /* RST are sent similarly to frame acks */
        if (h2s->st == H2_SS_ERROR || h2s->flags & H2_SF_RST_RCVD) {
                TRACE_DEVEL("reporting RST/error to the app-layer stream", H2_EV_H2S_SEND|H2_EV_H2S_ERR|H2_EV_STRM_ERR, h2s->h2c->conn, h2s);
-               cs_set_error(cs);
+               cs_ep_set_error(cs->endp);
                if (h2s_send_rst_stream(h2s->h2c, h2s) > 0)
                        h2s_close(h2s);
        }