From 1d9877700ed732278dc8c60fa16da6523273d6a0 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 29 Mar 2022 18:03:35 +0200 Subject: [PATCH] MINOR: stream-int/conn-stream: Move half-close timeout in the conn-stream The half-close timeout (hcto) is now part of the conn-stream. It is a step closer to the stream-interface removal. --- include/haproxy/conn_stream-t.h | 1 + include/haproxy/stream_interface-t.h | 1 - src/cli.c | 2 +- src/conn_stream.c | 1 + src/proxy.c | 2 +- src/stream.c | 4 ++-- src/stream_interface.c | 12 ++++++------ 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index fdaa6c3b2..55f338b09 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -124,6 +124,7 @@ struct conn_stream { enum obj_type obj_type; /* differentiates connection from applet context */ /* 3 bytes hole here */ unsigned int flags; /* CS_FL_* */ + unsigned int hcto; /* half-closed timeout (0 = unset) */ struct cs_endpoint *endp; /* points to the end point (MUX stream or appctx) */ enum obj_type *app; /* points to the applicative point (stream or check) */ struct stream_interface *si; diff --git a/include/haproxy/stream_interface-t.h b/include/haproxy/stream_interface-t.h index d9f1242c0..d01cea294 100644 --- a/include/haproxy/stream_interface-t.h +++ b/include/haproxy/stream_interface-t.h @@ -130,7 +130,6 @@ struct stream_interface { /* struct members below are the "remote" part, as seen from the buffer side */ unsigned int err_type; /* first error detected, one of SI_ET_* */ - unsigned int hcto; /* half-closed timeout (0 = unset) */ struct wait_event wait_event; /* We're in a wait list */ }; diff --git a/src/cli.c b/src/cli.c index 9b5337060..a1ab7e2d1 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2822,7 +2822,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) s->res.rex = TICK_ETERNITY; s->res.wex = TICK_ETERNITY; s->res.analyse_exp = TICK_ETERNITY; - cs_si(s->csb)->hcto = TICK_ETERNITY; + s->csb->hcto = TICK_ETERNITY; /* we're removing the analysers, we MUST re-enable events detection. * We don't enable close on the response channel since it's either diff --git a/src/conn_stream.c b/src/conn_stream.c index 55dd86cd9..e5a3ad79a 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -57,6 +57,7 @@ struct conn_stream *cs_new(struct cs_endpoint *endp) cs->obj_type = OBJ_TYPE_CS; cs->flags = CS_FL_NONE; + cs->hcto = TICK_ETERNITY; cs->app = NULL; cs->si = NULL; cs->data_cb = NULL; diff --git a/src/proxy.c b/src/proxy.c index 502417873..70710d023 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -2310,7 +2310,7 @@ int stream_set_backend(struct stream *s, struct proxy *be) cs_si(s->csb)->flags |= SI_FL_INDEP_STR; if (tick_isset(be->timeout.serverfin)) - cs_si(s->csb)->hcto = be->timeout.serverfin; + s->csb->hcto = be->timeout.serverfin; /* We want to enable the backend-specific analysers except those which * were already run as part of the frontend/listener. Note that it would diff --git a/src/stream.c b/src/stream.c index 200f69efd..eceea2eb2 100644 --- a/src/stream.c +++ b/src/stream.c @@ -454,13 +454,13 @@ struct stream *stream_new(struct session *sess, struct conn_stream *cs, struct b goto out_fail_alloc_csb; si_set_state(cs_si(s->csf), SI_ST_EST); - cs_si(s->csf)->hcto = sess->fe->timeout.clientfin; + s->csf->hcto = sess->fe->timeout.clientfin; if (likely(sess->fe->options2 & PR_O2_INDEPSTR)) cs_si(s->csf)->flags |= SI_FL_INDEP_STR; cs_si(s->csb)->flags = SI_FL_ISBACK; - cs_si(s->csb)->hcto = TICK_ETERNITY; + s->csb->hcto = TICK_ETERNITY; if (likely(sess->fe->options2 & PR_O2_INDEPSTR)) cs_si(s->csb)->flags |= SI_FL_INDEP_STR; diff --git a/src/stream_interface.c b/src/stream_interface.c index b4d7cab75..9be918b3f 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -237,8 +237,8 @@ static void stream_int_shutw(struct stream_interface *si) oc->wex = TICK_ETERNITY; si_done_get(si); - if (tick_isset(si->hcto)) { - ic->rto = si->hcto; + if (tick_isset(si->cs->hcto)) { + ic->rto = si->cs->hcto; ic->rex = tick_add(now_ms, ic->rto); } @@ -1106,8 +1106,8 @@ static void stream_int_shutw_conn(struct stream_interface *si) oc->wex = TICK_ETERNITY; si_done_get(si); - if (tick_isset(si->hcto)) { - ic->rto = si->hcto; + if (tick_isset(si->cs->hcto)) { + ic->rto = si->cs->hcto; ic->rex = tick_add(now_ms, ic->rto); } @@ -1756,8 +1756,8 @@ static void stream_int_shutw_applet(struct stream_interface *si) oc->wex = TICK_ETERNITY; si_done_get(si); - if (tick_isset(si->hcto)) { - ic->rto = si->hcto; + if (tick_isset(si->cs->hcto)) { + ic->rto = si->cs->hcto; ic->rex = tick_add(now_ms, ic->rto); }