]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: Allocate backend CS when the stream is created
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 Dec 2021 15:11:28 +0000 (16:11 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Feb 2022 10:00:02 +0000 (11:00 +0100)
Because the backend conn-stream is no longer released during connection
retry and because it is valid to have conn-stream with no connection, it is
possible to allocated it when the stream is created. This means, from now, a
stream has always valid frontend and backend conn-streams. It is the first
step to merge the SI and the CS.

src/stream.c

index f934ea0941f2804d951465b1ce3914979de331a1..619d04eda66c893b2bb5e630ec3581bd1a7f43ff 100644 (file)
@@ -494,6 +494,9 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
        if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
                s->si[1].flags |= SI_FL_INDEP_STR;
 
+       if (!si_alloc_cs(&s->si[1], NULL))
+               goto out_fail_alloc_cs;
+
        stream_init_srv_conn(s);
        s->target = sess->listener ? sess->listener->default_target : NULL;
 
@@ -591,7 +594,9 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
        task_destroy(t);
        tasklet_free(s->si[1].wait_event.tasklet);
        LIST_DELETE(&s->list);
-out_fail_alloc_si1:
+ out_fail_alloc_cs:
+       si_release_endpoint(&s->si[1]);
+ out_fail_alloc_si1:
        tasklet_free(s->si[0].wait_event.tasklet);
  out_fail_alloc:
        pool_free(pool_head_stream, s);