diff --git a/include/proto/connection.h b/include/proto/connection.h index 0efce993b..64117641c 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -505,17 +505,21 @@ static inline void conn_sock_read0(struct connection *c) } /* write shutdown, indication that the upper layer is not willing to send - * anything anymore and wants to close after pending data are sent. + * anything anymore and wants to close after pending data are sent. The + * argument will allow not to perform the socket layer shutdown if + * equal to 0. */ -static inline void conn_sock_shutw(struct connection *c) +static inline void conn_sock_shutw(struct connection *c, int clean) { c->flags |= CO_FL_SOCK_WR_SH; conn_refresh_polling_flags(c); __conn_sock_stop_send(c); conn_cond_update_sock_polling(c); - /* don't perform a clean shutdown if we're going to reset */ - if (conn_ctrl_ready(c) && !fdtab[c->handle.fd].linger_risk) + /* 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) shutdown(c->handle.fd, SHUT_WR); } diff --git a/src/mux_pt.c b/src/mux_pt.c index b32fa8edc..a68b96215 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -151,7 +151,7 @@ static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode) if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutw) cs->conn->xprt->shutw(cs->conn, (mode == CS_SHW_NORMAL)); if (!(cs->flags & CS_FL_SHR)) - conn_sock_shutw(cs->conn); + conn_sock_shutw(cs->conn, (mode == CS_SHW_NORMAL)); else conn_full_close(cs->conn); }