]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: Set SC_FL_ERROR on connection error
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 09:35:07 +0000 (11:35 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 15:05:53 +0000 (17:05 +0200)
During connection establishement, if an error occurred, the SC_FL_ERROR flag
is now set. Concretely, it is set when SE_FL_ERROR is also set.

src/backend.c

index 7bc321b1c3b1237b1b50d1ee4d3523303c0b8f4f..324ac9b63bf71071f12216f7ed8f2e1e4f753f65 100644 (file)
@@ -1822,8 +1822,10 @@ skip_reuse:
         * sockets, socket pairs, andoccasionally TCP connections on the
         * loopback on a heavily loaded system.
         */
-       if (srv_conn->flags & CO_FL_ERROR)
+       if (srv_conn->flags & CO_FL_ERROR) {
                sc_ep_set(s->scb, SE_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,
@@ -2025,6 +2027,7 @@ void back_try_conn_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->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
 
@@ -2045,6 +2048,7 @@ void back_try_conn_req(struct stream *s)
                 */
                sc->state = SC_ST_CER;
                sc_ep_clr(sc, SE_FL_ERROR);
+               sc->flags &= ~SC_FL_ERROR;
                back_handle_st_cer(s);
 
                DBG_TRACE_STATE("connection error, retry", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s);
@@ -2185,6 +2189,7 @@ 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;
                        if (s->srv_error)
@@ -2211,6 +2216,7 @@ 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;
                if (!s->conn_err_type)
                        s->conn_err_type = STRM_ET_CONN_OTHER;
                sc->state = SC_ST_CLO;
@@ -2345,6 +2351,7 @@ 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;
                if (s->srv_error)
@@ -2378,6 +2385,7 @@ 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;
                if (s->srv_error)