]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: link the stream to its session
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Jun 2017 13:20:05 +0000 (15:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Aug 2017 11:26:35 +0000 (13:26 +0200)
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.

include/types/stream.h
src/peers.c
src/stream.c

index 227b0ffbab705f5edc4f2ebaa0b557509d775a2b..bc18f2c593b63ecd1719c70688eca1886904147b 100644 (file)
@@ -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 */
index 7bf7766ea25a04861e88387f6f97a8fa5ba9aff1..249edf7a314c0907296a9afc7b1e18e5726df9b2 100644 (file)
@@ -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:
index 3a88fd47c54bb7e6c61bc95da2eebb56ea4b5ce9..43196675b968cfe00a72742c9821998206825001 100644 (file)
@@ -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]);