BUG/MEDIUM: ring: write-lock the ring while attaching/detaching
authorWilly Tarreau <w@1wt.eu>
Tue, 19 May 2020 17:21:45 +0000 (19:21 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 May 2020 17:13:10 +0000 (19:13 +0200)
commited7487c65cce1f86cb5cae9fd95dc208aedd69a1
treeb911fa01163dc67c781efb90a1d6dfc691de4a75
parent7622ee2949f882e7da08cecf6839cb78085e4ec8
BUG/MEDIUM: ring: write-lock the ring while attaching/detaching

The LIST_ADDQ() and LIST_DEL_INIT() calls made to attach/detach a waiter
to the ring were made under a read lock which was sufficient in front of
the writer's write lock. But it's not sufficient against other readers!
Thus theorically multiple "show events" on the same ring buffer on the
CLI could result in a crash, even though for now I couldn't manage to
reproduce it.

This fixes commit 1d181e489c ("MEDIUM: ring: implement a wait mode for
watchers") so it must be backported to 2.1, possibly further if the ring
code gets backported.

(cherry picked from commit 223ddedb467494d78ebf67e0ac19206f767ffe6a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/ring.c