]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: make stream_new() always set the target and analysers
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Dec 2016 23:26:31 +0000 (00:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 27 Jun 2017 12:38:02 +0000 (14:38 +0200)
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.

src/session.c
src/stream.c

index 46b9f67e3c9c58e754f6fa70dba03e5c7c0dc895..429577716bf57fd27f982ecbff2d4df69bf04612 100644 (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);
index 78748373f9e04460c67c6b6a79027f5626d2a7d8..8e7ac60880ddbc06be281543ea0984bcf7db9311 100644 (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 */