From 9568d7108f339830f28d665ece1e2b161380b6b5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 30 Dec 2012 01:39:37 +0100 Subject: 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. --- src/stream_interface.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stream_interface.c b/src/stream_interface.c index ecd7e4c..8a21d39 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); -- 1.7.12.2.21.g234cd45.dirty