From 0ad46fa6f5bc0ccb2514150661b389c14abbf1d8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 17 May 2019 14:20:05 +0200 Subject: [PATCH] MINOR: stream: detach the stream from its own task on stream_free() 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stream.c b/src/stream.c index 62c559847..2b2d39939 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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 */