]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: detach the stream from its own task on stream_free()
authorWilly Tarreau <w@1wt.eu>
Fri, 17 May 2019 12:20:05 +0000 (14:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 May 2019 15:16:20 +0000 (17:16 +0200)
This makes sure that the stream is not visible from its own task just
before starting to free some of its components. This way we have the
guarantee that a stream found in a task list is totally valid and can
safely be dereferenced.

src/stream.c

index 62c559847d378ef6a5538e577deedeaa3fe9cad7..2b2d39939efbedf0c1a2c730a104ebda7cb5ef62 100644 (file)
@@ -364,6 +364,12 @@ static void stream_free(struct stream *s)
        int must_free_sess;
        int i;
 
+       /* detach the stream from its own task before even releasing it so
+        * that walking over a task list never exhibits a dying stream.
+        */
+       s->task->context = NULL;
+       __ha_barrier_store();
+
        pendconn_free(s);
 
        if (objt_server(s->target)) { /* there may be requests left pending in queue */