BUG/MEDIUM: trace: avoid race condition when retrieving session from conn->owner
There's a rare race condition possible when trying to retrieve session from
a back connection's owner, that was fixed in 2.4 and described in commit
3aab17bd5 ("BUG/MAJOR: connection: reset conn->owner when detaching from
session list").
It also affects the trace code which does the same, so the same fix is
needed, i.e. check from conn->session_list that the connection is still
enlisted. It's visible when sending a few tens to hundreds of parallel
requests to an h2 backend and enabling traces in parallel.
This should be backported as far as 2.2 which is the oldest version
supporting traces.
(cherry picked from commit 6e805dab2add31c7a60f2f4be933f8e6903151fe)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d50fe5f48646f36c55b0575dd2316b4fc860cd2d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/trace.c b/src/trace.c
index f075787..4c5270c 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -114,7 +114,7 @@
if (!sess && strm)
sess = strm->sess;
- else if (!sess && conn)
+ else if (!sess && conn && LIST_INLIST(&conn->session_list))
sess = conn->owner;
else if (!sess && check)
sess = check->sess;