From: Willy Tarreau Date: Tue, 27 Jun 2017 13:20:05 +0000 (+0200) Subject: MINOR: stream: link the stream to its session X-Git-Tag: v1.8-dev3~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bfd35885ee1fb73461477e3237b28f4d6c7f2f8;p=thirdparty%2Fhaproxy.git MINOR: stream: link the stream to its session Now each stream is added to the session's list of streams, so that it will be possible to know all the streams belonging to a session, and to know if any stream is still attached to a sessoin. --- diff --git a/include/types/stream.h b/include/types/stream.h index 227b0ffbab..bc18f2c593 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -133,6 +133,7 @@ struct stream { * This is a bit field of TASK_WOKEN_* */ struct list list; /* position in global streams list */ + struct list by_sess; /* position in the session's streams list */ struct list by_srv; /* position in server stream list */ struct list back_refs; /* list of users tracking this stream */ struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */ diff --git a/src/peers.c b/src/peers.c index 7bf7766ea2..249edf7a31 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1856,6 +1856,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer /* Error unrolling */ out_free_strm: + LIST_DEL(&s->by_sess); LIST_DEL(&s->list); pool_free2(pool2_stream, s); out_free_task: diff --git a/src/stream.c b/src/stream.c index 3a88fd47c5..43196675b9 100644 --- a/src/stream.c +++ b/src/stream.c @@ -135,6 +135,7 @@ struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *o /* OK, we're keeping the stream, so let's properly initialize the stream */ LIST_ADDQ(&streams, &s->list); + LIST_ADDQ(&sess->streams, &s->by_sess); LIST_INIT(&s->back_refs); LIST_INIT(&s->buffer_wait.list); @@ -249,6 +250,7 @@ struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *o /* Error unrolling */ out_fail_accept: flt_stream_release(s, 0); + LIST_DEL(&s->by_sess); LIST_DEL(&s->list); pool_free2(pool2_stream, s); return NULL; @@ -348,6 +350,7 @@ static void stream_free(struct stream *s) LIST_ADDQ(&LIST_ELEM(s->list.n, struct stream *, list)->back_refs, &bref->users); bref->ref = s->list.n; } + LIST_DEL(&s->by_sess); LIST_DEL(&s->list); si_release_endpoint(&s->si[1]); si_release_endpoint(&s->si[0]);