diff --git a/include/proto/connection.h b/include/proto/connection.h index 1e5fc9c9e..115e7aaa3 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -352,8 +352,7 @@ static inline void conn_sock_shutw(struct connection *c, int clean) /* don't perform a clean shutdown if we're going to reset or * if the shutr was already received. */ - if (conn_ctrl_ready(c) && !(c->flags & CO_FL_SOCK_RD_SH) && clean && - !fdtab[c->handle.fd].linger_risk) + if (conn_ctrl_ready(c) && !(c->flags & CO_FL_SOCK_RD_SH) && clean) shutdown(c->handle.fd, SHUT_WR); } diff --git a/src/checks.c b/src/checks.c index e31eb1735..68da2a376 100644 --- a/src/checks.c +++ b/src/checks.c @@ -1382,6 +1382,11 @@ static void __event_srv_chk_r(struct conn_stream *cs) * range quickly. To avoid sending RSTs all the time, we first try to * drain pending data. */ + /* Call cs_shutr() first, to add the CO_FL_SOCK_RD_SH flag on the + * connection, to make sure cs_shutw() will not lead to a shutdown() + * that would provoke TIME_WAITs. + */ + cs_shutr(cs, CS_SHR_DRAIN); cs_shutw(cs, CS_SHW_NORMAL); /* OK, let's not stay here forever */