From: Willy Tarreau Date: Sun, 4 Dec 2016 23:26:31 +0000 (+0100) Subject: MEDIUM: stream: make stream_new() always set the target and analysers X-Git-Tag: v1.8-dev3~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b82d941c58183efe43a49da73927e537aacef90;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/session.c b/src/session.c index 46b9f67e3c..429577716b 100644 --- a/src/session.c +++ b/src/session.c @@ -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); diff --git a/src/stream.c b/src/stream.c index 78748373f9..8e7ac60880 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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 */