From e2b38b31bb90bfe12b2d5dc348510e39e0c52775 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 16 Dec 2021 16:11:28 +0100 Subject: [PATCH] MEDIUM: stream: Allocate backend CS when the stream is created 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index f934ea094..619d04eda 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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);