From: Willy Tarreau Date: Thu, 23 Jan 2020 17:05:18 +0000 (+0100) Subject: MINOR: connection: do not check for CO_FL_SOCK_RD_SH too early X-Git-Tag: v2.2-dev2~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d838fb840c3752630f5ddaaf8ef805b8e310f102;p=thirdparty%2Fhaproxy.git MINOR: connection: do not check for CO_FL_SOCK_RD_SH too early The handshake functions dedicated to proxy proto, netscaler and socks4 all check for this flag before proceeding. This is wrong, they must not do and instead perform the call to recv() then report the close. The reason for this is that the current construct managed to lose the CO_ER_CIP_EMPTY error code in case the connection was already shut, thus causing a race condition with some errors being reported correctly or as unknown depending on the timing. --- diff --git a/src/connection.c b/src/connection.c index dcecf14096..83790a9d9a 100644 --- a/src/connection.c +++ b/src/connection.c @@ -493,10 +493,6 @@ int conn_recv_proxy(struct connection *conn, int flag) int tlv_offset = 0; int ret; - /* we might have been called just after an asynchronous shutr */ - if (conn->flags & CO_FL_SOCK_RD_SH) - goto fail; - if (!conn_ctrl_ready(conn)) goto fail; @@ -825,10 +821,6 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag) uint8_t ip_ver; int ret; - /* we might have been called just after an asynchronous shutr */ - if (conn->flags & CO_FL_SOCK_RD_SH) - goto fail; - if (!conn_ctrl_ready(conn)) goto fail; @@ -1094,10 +1086,6 @@ int conn_recv_socks4_proxy_response(struct connection *conn) char line[SOCKS4_HS_RSP_LEN]; int ret; - /* we might have been called just after an asynchronous shutr */ - if (conn->flags & CO_FL_SOCK_RD_SH) - goto fail; - if (!conn_ctrl_ready(conn)) goto fail;