]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ring: resize only under thread isolation
authorWilly Tarreau <w@1wt.eu>
Wed, 28 Feb 2024 08:45:54 +0000 (09:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
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

index 14f374bfbf585bcfca42300f29c1e9b559adf4ac..c2668afeca31ed37a0818bdd56c6a2df63780a58 100644 (file)
@@ -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);