From 36c23883fe3e0ae05f102d62e766e39a403ed912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Border=C3=A9?= Date: Thu, 27 Jul 2023 12:29:51 +0200 Subject: [PATCH] uv_append: Initialize barrier upon creation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Borderé --- src/uv_append.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uv_append.c b/src/uv_append.c index e5c535b53..25573a619 100644 --- a/src/uv_append.c +++ b/src/uv_append.c @@ -790,13 +790,14 @@ static void uvBarrierTriggerAll(struct UvBarrier *barrier) } } -struct UvBarrier *uvBarrierAlloc(void) +static struct UvBarrier *uvBarrierCreate(void) { struct UvBarrier *barrier; - barrier = RaftHeapMalloc(sizeof(*barrier)); + barrier = RaftHeapCalloc(1, sizeof(*barrier)); if (!barrier) { return NULL; } + barrier->blocking = false; QUEUE_INIT(&barrier->reqs); return barrier; } @@ -829,7 +830,7 @@ int UvBarrier(struct uv *uv, raft_index next_index, struct UvBarrierReq *req) } if (!barrier) { - barrier = uvBarrierAlloc(); + barrier = uvBarrierCreate(); if (!barrier) { return RAFT_NOMEM; } @@ -856,7 +857,7 @@ int UvBarrier(struct uv *uv, raft_index next_index, struct UvBarrierReq *req) barrier = uv->barrier; /* There is no uv->barrier, make new one. */ } else { - barrier = uvBarrierAlloc(); + barrier = uvBarrierCreate(); if (!barrier) { return RAFT_NOMEM; }