From: Emeric Brun Date: Mon, 5 Mar 2018 16:46:16 +0000 (+0100) Subject: BUG/MINOR: session: Fix tcp-request session failure if handshake. X-Git-Tag: v1.9-dev1~386 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1738e86771cce2567483cde0ac23459be8e51ed8;p=thirdparty%2Fhaproxy.git BUG/MINOR: session: Fix tcp-request session failure if handshake. Some sample fetches check if session is established using the flag CO_FL_CONNECTED. But in some cases, when a handshake is performed this flag is set too late, after the process of the tcp-request session rules. This fix move the raising of the flag at the beginning of the conn_complete_session function which processes the tcp-request session rules. This fix must be backported to 1.8 (and perhaps 1.7) --- diff --git a/src/session.c b/src/session.c index 329877d296..ae98c9476d 100644 --- a/src/session.c +++ b/src/session.c @@ -264,8 +264,6 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr } /* OK let's complete stream initialization since there is no handshake */ - cli_conn->flags |= CO_FL_CONNECTED; - if (conn_complete_session(cli_conn) >= 0) return 1; @@ -402,6 +400,10 @@ static int conn_complete_session(struct connection *conn) conn_clear_xprt_done_cb(conn); + /* Verify if the connection just established. */ + if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED)))) + conn->flags |= CO_FL_CONNECTED; + if (conn->flags & CO_FL_ERROR) goto fail;