From: Willy Tarreau Date: Sun, 30 Dec 2012 00:39:37 +0000 (+0100) Subject: BUG/MEDIUM: stream_interface: don't close outgoing connections on shutw() X-Git-Tag: v1.5-dev18~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9568d7108f339830f28d665ece1e2b161380b6b5;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: stream_interface: don't close outgoing connections on shutw() Commit 7bb68abb introduced the SI_FL_NOHALF flag in dev10. It is used to automatically close the write side of a connection whose read side is closed. But the patch also caused the opposite to happen, which is that a simple shutw() call would immediately close the connection. This is not desired because when using option abortonclose, we want to pass the client's shutdown to the server which will decide what to do with it. So let's avoid the close when SHUTR is not set. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index ecd7e4c6b7..8a21d398a3 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -297,7 +297,13 @@ int stream_int_shutw(struct stream_interface *si) if (conn->xprt && conn->xprt->shutw) conn->xprt->shutw(conn, 1); - if (!(si->flags & SI_FL_NOHALF)) { + /* If the stream interface is configured to disable half-open + * connections, we'll skip the shutdown(), but only if the + * read size is already closed. Otherwise we can't support + * closed write with pending read (eg: abortonclose while + * waiting for the server). + */ + if (!(si->flags & SI_FL_NOHALF) || !(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) { /* We shutdown transport layer */ if (conn->ctrl) shutdown(si->conn->t.sock.fd, SHUT_WR);