diff --git a/include/haproxy/stream-t.h b/include/haproxy/stream-t.h index 9499e94d7..e5482a2e8 100644 --- a/include/haproxy/stream-t.h +++ b/include/haproxy/stream-t.h @@ -88,6 +88,7 @@ #define SF_IGNORE_PRST 0x00080000 /* ignore persistence */ #define SF_SRV_REUSED 0x00100000 /* the server-side connection was reused */ +#define SF_SRV_REUSED_ANTICIPATED 0x00200000 /* the connection was reused but the mux is not ready yet */ /* flags for the proxy of the master CLI */ diff --git a/src/backend.c b/src/backend.c index 35cf72787..638280581 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1591,16 +1591,15 @@ skip_reuse: } } else { + s->flags |= SF_SRV_REUSED; + /* Currently there seems to be no known cases of xprt ready * without the mux installed here. */ BUG_ON(!srv_conn->mux); - /* Only consider we're doing reuse if the connection was - * ready. - */ - if (srv_conn->mux->ctl(srv_conn, MUX_STATUS, NULL) & MUX_STATUS_READY) - s->flags |= SF_SRV_REUSED; + if (!(srv_conn->mux->ctl(srv_conn, MUX_STATUS, NULL) & MUX_STATUS_READY)) + s->flags |= SF_SRV_REUSED_ANTICIPATED; } /* flag for logging source ip/port */ @@ -2273,6 +2272,8 @@ void back_handle_st_cer(struct stream *s) */ int delay = 1000; + const int reused = (s->flags & SF_SRV_REUSED) && + !(s->flags & SF_SRV_REUSED_ANTICIPATED); if (s->be->timeout.connect && s->be->timeout.connect < delay) delay = s->be->timeout.connect; @@ -2283,7 +2284,7 @@ void back_handle_st_cer(struct stream *s) /* only wait when we're retrying on the same server */ if ((si->state == SI_ST_ASS || (s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_RR || - (s->be->srv_act <= 1)) && !(s->flags & SF_SRV_REUSED)) { + (s->be->srv_act <= 1)) && !reused) { si->state = SI_ST_TAR; si->exp = tick_add(now_ms, MS_TO_TICKS(delay)); }