]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stream_interface: don't close outgoing connections on shutw()
authorWilly Tarreau <w@1wt.eu>
Sun, 30 Dec 2012 00:39:37 +0000 (01:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 30 Dec 2012 00:39:37 +0000 (01:39 +0100)
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

index ecd7e4c6b7185d090267be089719e566b4914dc1..8a21d398a3e13ad88ec11dd1f832477ca33a5f24 100644 (file)
@@ -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);