diff --git a/src/peers.c b/src/peers.c index 0c8861f39..beeec96f5 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1719,7 +1719,13 @@ static void peer_session_forceshutdown(struct appctx *appctx) { struct peer *ps; - if (!appctx) + /* Note that the peer sessions which have just been created + * (->st0 == PEER_SESS_ST_CONNECT) must not + * be shutdown, if not, the TCP session will never be closed + * and stay in CLOSE_WAIT state after having been closed by + * the remote side. + */ + if (!appctx || appctx->st0 == PEER_SESS_ST_CONNECT) return; if (appctx->applet != &peer_applet)