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.
This commit is contained in:
Willy Tarreau 2015-04-08 18:18:15 +02:00
parent 042cd75bc2
commit 678be62981
2 changed files with 15 additions and 9 deletions

View 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:

View 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.