]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn: Set half-close timeout using proxy settings
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 20 Feb 2023 07:36:53 +0000 (08:36 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 22 Feb 2023 14:59:16 +0000 (15:59 +0100)
We now directly use the proxy settings to set the half-close timeout of a
stream-connector. The function sc_set_hcto() must be used to do so. This
timeout is only set when a shutw is performed. So it is not really a big
deal to use a dedicated function to do so.

include/haproxy/sc_strm.h
src/stconn.c

index e58499d7a0482d40e54c0621dfc0af21a3f5ce84..579409271b783fae47953a646aea92bd11523ce2 100644 (file)
@@ -401,4 +401,19 @@ static inline void sc_check_timeouts(const struct stconn *sc)
                sc_oc(sc)->flags |= CF_WRITE_TIMEOUT;
 }
 
+static inline void sc_set_hcto(struct stconn *sc)
+{
+       struct stream *strm = __sc_strm(sc);
+
+       if (sc->flags & SC_FL_ISBACK) {
+               if ((strm->flags & SF_BE_ASSIGNED) && tick_isset(strm->be->timeout.serverfin))
+                       sc->ioto = strm->be->timeout.serverfin;
+       }
+       else {
+               if (tick_isset(strm_fe(strm)->timeout.clientfin))
+                       sc->ioto = strm_fe(strm)->timeout.clientfin;
+       }
+
+}
+
 #endif /* _HAPROXY_SC_STRM_H */
index ae537661f0becdcec23238e129849a49026ed4c3..6cf4830ceacbc0b2b3e401722636c49b53071720 100644 (file)
@@ -568,9 +568,7 @@ static void sc_app_shutw(struct stconn *sc)
        if (oc->flags & CF_SHUTW)
                return;
        oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
-
-       if (tick_isset(sc->hcto))
-               sc->ioto = sc->hcto;
+       sc_set_hcto(sc);
 
        switch (sc->state) {
        case SC_ST_RDY:
@@ -701,9 +699,7 @@ static void sc_app_shutw_conn(struct stconn *sc)
        if (oc->flags & CF_SHUTW)
                return;
        oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
-
-       if (tick_isset(sc->hcto))
-               sc->ioto = sc->hcto;
+       sc_set_hcto(sc);
 
        switch (sc->state) {
        case SC_ST_RDY:
@@ -898,9 +894,7 @@ static void sc_app_shutw_applet(struct stconn *sc)
        if (oc->flags & CF_SHUTW)
                return;
        oc->flags |= CF_SHUTW|CF_WRITE_EVENT;
-
-       if (tick_isset(sc->hcto))
-               sc->ioto = sc->hcto;
+       sc_set_hcto(sc);
 
        /* on shutw we always wake the applet up */
        appctx_wakeup(__sc_appctx(sc));