From 0fa05ce171cd28c594762fe7b1b5f10d2b853068 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 28 Feb 2024 09:45:54 +0100 Subject: [PATCH] MINOR: ring: resize only under thread isolation The ring resizing was already quite tricky, but when facing atomic writes it will no longer be possible and we definitely do not want to have to deal with a lock there. Since it's only done at boot time, and possibly later from the CLI, let's just do it under thread isolation. --- src/ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ring.c b/src/ring.c index 14f374b..c2668af 100644 --- a/src/ring.c +++ b/src/ring.c @@ -122,7 +122,7 @@ struct ring *ring_resize(struct ring *ring, size_t size) if (!new) return NULL; - HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock); + thread_isolate(); /* recheck the buffer's size, it may have changed during the malloc */ @@ -135,7 +135,7 @@ struct ring *ring_resize(struct ring *ring, size_t size) /* new is now the old one */ } - HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock); + thread_release(); /* free the unused one */ free(new); -- 1.7.10.4