]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection: local_send_proxy must wait for connection to establish
authorWilly Tarreau <w@1wt.eu>
Sat, 24 Nov 2012 10:23:04 +0000 (11:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 24 Nov 2012 10:23:04 +0000 (11:23 +0100)
The conn_local_send_proxy() function has to retrieve the local and remote
addresses, but the getpeername() and getsockname() functions may fail until
the connection is established. So now we catch this error and poll for write
when this happens.

src/connection.c

index 38d4ca6289da2b495405db8f1b792c5621e2ba8f..d882bb74d3345462fc09298a22878ef3a515503b 100644 (file)
@@ -531,14 +531,16 @@ int conn_local_send_proxy(struct connection *conn, unsigned int flag)
        if (conn->flags & CO_FL_SOCK_WR_SH)
                goto out_error;
 
-       /* The target server expects a PROXY line to be sent first. */
+       /* The target server expects a PROXY line to be sent first. Retrieving
+        * local or remote addresses may fail until the connection is established.
+        */
        conn_get_from_addr(conn);
        if (!(conn->flags & CO_FL_ADDR_FROM_SET))
-               goto out_error;
+               goto out_wait;
 
        conn_get_to_addr(conn);
        if (!(conn->flags & CO_FL_ADDR_TO_SET))
-               goto out_error;
+               goto out_wait;
 
        trash.len = make_proxy_line(trash.str, trash.size, &conn->addr.from, &conn->addr.to);
        if (!trash.len)