MEDIUM: stream: make stream_new() always set the target and analysers

It doesn't make sense that stream_new() doesn't sets the target nor
analysers and that the caller has to do it even if it doesn't know
about streams (eg: in session_accept_fd()). This causes trouble for
H2 where the applet handling the protocol cannot properly change
these information during its init phase.

Let's ensure it's always set and that the callers don't set it anymore.

Note: peers and lua don't use analysers and that's properly handled.
This commit is contained in:
Willy Tarreau 2016-12-05 00:26:31 +01:00
parent f3a55dbd22
commit 9b82d941c5
2 changed files with 5 additions and 13 deletions

View File

@ -116,7 +116,6 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
struct connection *cli_conn;
struct proxy *p = l->bind_conf->frontend;
struct session *sess;
struct stream *strm;
struct task *t;
int ret;
@ -269,13 +268,9 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
goto out_free_sess;
session_count_new(sess);
strm = stream_new(sess, t, &cli_conn->obj_type);
if (!strm)
if (!stream_new(sess, t, &cli_conn->obj_type))
goto out_free_task;
strm->target = sess->listener->default_target;
strm->req.analysers |= sess->listener->analysers;
task_wakeup(t, TASK_WOKEN_INIT);
return 1;
@ -424,7 +419,6 @@ static int conn_complete_session(struct connection *conn)
{
struct task *task = conn->owner;
struct session *sess = task->context;
struct stream *strm;
if (conn->flags & CO_FL_ERROR)
goto fail;
@ -439,12 +433,9 @@ static int conn_complete_session(struct connection *conn)
session_count_new(sess);
task->process = sess->listener->handler;
strm = stream_new(sess, task, &conn->obj_type);
if (!strm)
if (!stream_new(sess, task, &conn->obj_type))
goto fail;
strm->target = sess->listener->default_target;
strm->req.analysers |= sess->listener->analysers;
conn->flags &= ~CO_FL_INIT_DATA;
task_wakeup(task, TASK_WOKEN_INIT);

View File

@ -189,7 +189,8 @@ struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *o
s->si[1].flags |= SI_FL_INDEP_STR;
stream_init_srv_conn(s);
s->target = NULL;
s->target = sess->listener ? sess->listener->default_target : NULL;
s->pend_pos = NULL;
/* init store persistence */
@ -197,7 +198,7 @@ struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *o
channel_init(&s->req);
s->req.flags |= CF_READ_ATTACHED; /* the producer is already connected */
s->req.analysers = 0;
s->req.analysers = sess->listener ? sess->listener->analysers : 0;
channel_auto_connect(&s->req); /* don't wait to establish connection */
channel_auto_close(&s->req); /* let the producer forward close requests */