From: Willy Tarreau Date: Wed, 28 Feb 2024 08:45:54 +0000 (+0100) Subject: MINOR: ring: resize only under thread isolation X-Git-Tag: v3.0-dev6~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fa05ce171cd28c594762fe7b1b5f10d2b853068;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/ring.c b/src/ring.c index 14f374bfbf..c2668afeca 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);