]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: tree-wide: Stop to set SE_FL_ERROR from upper layer
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 10:03:50 +0000 (12:03 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 15:05:54 +0000 (17:05 +0200)
We can now fully rely on SC_FL_ERROR flag from the stream. The first step is
to stop to set the SE_FL_ERROR flag. Only endpoints are responsible to set
this flag. It was a design limitation. It is now fixed.

src/backend.c
src/stconn.c
src/stream.c

index 9b7e9e1e24e0dbdaf177c2fe58ebd26909d1ed4d..2d4ea4b28c1920f9a96638b155d1181e50b64cdd 100644 (file)
@@ -1822,10 +1822,8 @@ skip_reuse:
         * sockets, socket pairs, andoccasionally TCP connections on the
         * loopback on a heavily loaded system.
         */
-       if (srv_conn->flags & CO_FL_ERROR) {
-               sc_ep_set(s->scb, SE_FL_ERROR);
+       if (srv_conn->flags & CO_FL_ERROR)
                s->scb->flags |= SC_FL_ERROR;
-       }
 
        /* If we had early data, and the handshake ended, then
         * we can remove the flag, and attempt to wake the task up,
@@ -2026,7 +2024,6 @@ void back_try_conn_req(struct stream *s)
                        /* Failed and not retryable. */
                        sc_abort(sc);
                        sc_shutdown(sc);
-                       sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                        sc->flags |= SC_FL_ERROR;
 
                        s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@@ -2047,7 +2044,6 @@ void back_try_conn_req(struct stream *s)
                 * allocation problem, so we want to retry now.
                 */
                sc->state = SC_ST_CER;
-               sc_ep_clr(sc, SE_FL_ERROR);
                sc->flags &= ~SC_FL_ERROR;
                back_handle_st_cer(s);
 
@@ -2188,7 +2184,6 @@ void back_handle_st_req(struct stream *s)
 
                        sc_abort(sc);
                        sc_shutdown(sc);
-                       sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                        sc->flags |= SC_FL_ERROR;
                        s->conn_err_type = STRM_ET_CONN_RES;
                        sc->state = SC_ST_CLO;
@@ -2215,7 +2210,6 @@ void back_handle_st_req(struct stream *s)
                /* we did not get any server, let's check the cause */
                sc_abort(sc);
                sc_shutdown(sc);
-               sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                sc->flags |= SC_FL_ERROR;
                if (!s->conn_err_type)
                        s->conn_err_type = STRM_ET_CONN_OTHER;
@@ -2350,7 +2344,6 @@ void back_handle_st_cer(struct stream *s)
 
                /* shutw is enough to stop a connecting socket */
                sc_shutdown(sc);
-               sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                sc->flags |= SC_FL_ERROR;
 
                sc->state = SC_ST_CLO;
@@ -2369,7 +2362,7 @@ void back_handle_st_cer(struct stream *s)
         * layers in an unexpected state (i.e < ST_CONN).
         *
         * Note: the stream connector will be switched to ST_REQ, ST_ASS or
-        * ST_TAR and SE_FL_ERROR and SF_CONN_EXP flags will be unset.
+        * ST_TAR and SC_FL_ERROR and SF_CONN_EXP flags will be unset.
         */
        if (sc_reset_endp(sc) < 0) {
                if (!s->conn_err_type)
@@ -2384,7 +2377,6 @@ void back_handle_st_cer(struct stream *s)
 
                /* shutw is enough to stop a connecting socket */
                sc_shutdown(sc);
-               sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                sc->flags |= SC_FL_ERROR;
 
                sc->state = SC_ST_CLO;
index 6b2397c5f254dcd4d17296d55dd0f348a53839c4..f4d54a7c6ed68163b0f0b98766fcfb8a16b09224 100644 (file)
@@ -1725,11 +1725,11 @@ static int sc_conn_process(struct stconn *sc)
 
        /* First step, report to the stream connector what was detected at the
         * connection layer : errors and connection establishment.
-        * Only add SE_FL_ERROR if we're connected, or we're attempting to
+        * Only add SC_FL_ERROR if we're connected, or we're attempting to
         * connect, we may get there because we got woken up, but only run
         * after process_stream() noticed there were an error, and decided
         * to retry to connect, the connection may still have CO_FL_ERROR,
-        * and we don't want to add SE_FL_ERROR back
+        * and we don't want to add SC_FL_ERROR back
         *
         * Note: This test is only required because sc_conn_process is also the SI
         *       wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
@@ -1737,10 +1737,8 @@ static int sc_conn_process(struct stconn *sc)
         */
 
        if (sc->state >= SC_ST_CON) {
-               if (sc_is_conn_error(sc)) {
-                       sc_ep_set(sc, SE_FL_ERROR);
+               if (sc_is_conn_error(sc))
                        sc->flags |= SC_FL_ERROR;
-               }
        }
 
        /* If we had early data, and the handshake ended, then
index 36af89f37e5f6405dfdce11d6d7d3faa3130c4df..238b49ce889aac7fb450043546fd204f21bc92cd 100644 (file)
@@ -1805,11 +1805,9 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
         *       must be be reviewed too.
         */
        if (!stream_alloc_work_buffer(s)) {
-               sc_ep_set(s->scf, SE_FL_ERROR);
                scf->flags |= SC_FL_ERROR;
                s->conn_err_type = STRM_ET_CONN_RES;
 
-               sc_ep_set(s->scb, SE_FL_ERROR);
                scb->flags |= SC_FL_ERROR;
                s->conn_err_type = STRM_ET_CONN_RES;