]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: adjust the connection flags before stream_new()
authorWilly Tarreau <w@1wt.eu>
Wed, 8 Apr 2015 16:18:15 +0000 (18:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 8 Apr 2015 16:18:15 +0000 (18:18 +0200)
It's not the stream's job to manipulate the connection's flags, it's
more related to the session that accepted the new connection. And the
only case where we have to do it conditionally is based on the frontend
which is known from the session, thus it makes sense to do it there.

src/session.c
src/stream.c

index 604bfa97c5651c6b0a0fe413d73fd9916fe2ffe6..714d15ccf84eff4ffe97c4ffc6d9661de0246ba6 100644 (file)
@@ -251,6 +251,13 @@ 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;
 
+       /* we want the connection handler to notify the stream interface about updates. */
+       cli_conn->flags |= CO_FL_WAKE_DATA;
+
+       /* if logs require transport layer information, note it on the connection */
+       if (sess->fe->to_log & LW_XPRT)
+               cli_conn->flags |= CO_FL_XPRT_TRACKED;
+
        session_count_new(sess);
        strm = stream_new(sess, t);
        if (!strm)
@@ -408,6 +415,13 @@ static int conn_complete_session(struct connection *conn)
        if (conn->flags & CO_FL_ERROR)
                goto fail;
 
+       /* we want the connection handler to notify the stream interface about updates. */
+       conn->flags |= CO_FL_WAKE_DATA;
+
+       /* if logs require transport layer information, note it on the connection */
+       if (sess->fe->to_log & LW_XPRT)
+               conn->flags |= CO_FL_XPRT_TRACKED;
+
        session_count_new(sess);
        task->process = sess->listener->handler;
        strm = stream_new(sess, task);
@@ -417,6 +431,7 @@ static int conn_complete_session(struct connection *conn)
        strm->target        = sess->listener->default_target;
        strm->req.analysers = sess->listener->analysers;
        conn->flags &= ~CO_FL_INIT_DATA;
+
        return 0;
 
  fail:
index 9663747e1f08ec59828b5e0661e254a0f01de06e..ea24f9f427cdb04a502530ebeae7b083e04484f5 100644 (file)
@@ -204,15 +204,6 @@ struct stream *stream_new(struct session *sess, struct task *t)
        if (sess->fe->accept && sess->fe->accept(s) < 0)
                goto out_fail_accept;
 
-       if (conn) {
-               /* if logs require transport layer information, note it on the connection */
-               if (s->logs.logwait & LW_XPRT)
-                       conn->flags |= CO_FL_XPRT_TRACKED;
-
-               /* we want the connection handler to notify the stream interface about updates. */
-               conn->flags |= CO_FL_WAKE_DATA;
-       }
-
        /* it is important not to call the wakeup function directly but to
         * pass through task_wakeup(), because this one knows how to apply
         * priorities to tasks.