]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: only call tcp_connect_probe when nothing was attempted yet
authorWilly Tarreau <w@1wt.eu>
Sat, 1 Sep 2012 15:59:22 +0000 (17:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Sep 2012 18:47:35 +0000 (20:47 +0200)
It was observed that after a failed send() on EAGAIN, a second connect()
would still be attempted in tcp_connect_probe() because there was no way
to know that a send() had failed.

By checking the WANT_WR status flag, we know if a previous write attempt
failed on EAGAIN, so we don't try to connect again if we know this has
already failed.

With this simple change, the second connect() has disappeared.

src/connection.c

index 6ed44080c9806d76a45f914245087730e5fae64d..15b94856ffa48c6c4f277cb03872be0eb615549b 100644 (file)
@@ -89,9 +89,10 @@ int conn_fd_handler(int fd)
        if (unlikely(conn->flags & CO_FL_HANDSHAKE))
                goto process_handshake;
 
-       if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN)) {
-               /* still waiting for a connection to establish and no data to
-                * send in order to probe it ? Then let's retry the connect().
+       if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && !(conn->flags & CO_FL_WAIT_WR)) {
+               /* still waiting for a connection to establish and nothing was
+                * attempted yet to probe the connection. Then let's retry the
+                * connect().
                 */
                if (!tcp_connect_probe(conn))
                        goto leave;