From: Willy Tarreau Date: Wed, 8 Apr 2015 16:18:15 +0000 (+0200) Subject: MEDIUM: session: adjust the connection flags before stream_new() X-Git-Tag: v1.6-dev2~215 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=678be62981a59641025608291760232f821b38a9;p=thirdparty%2Fhaproxy.git MEDIUM: session: adjust the connection flags before stream_new() 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. --- diff --git a/src/session.c b/src/session.c index 604bfa97c5..714d15ccf8 100644 --- a/src/session.c +++ b/src/session.c @@ -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: diff --git a/src/stream.c b/src/stream.c index 9663747e1f..ea24f9f427 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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.