From 4c03889fe2dfee7f8b765e06c054214e658e0cc9 Mon Sep 17 00:00:00 2001 From: YiraSan Date: Mon, 11 Nov 2024 11:47:00 +0100 Subject: [PATCH] coro.Semaphore: fix infinite waiting --- src/coro/Sync.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coro/Sync.zig b/src/coro/Sync.zig index 505812e..2607a50 100644 --- a/src/coro/Sync.zig +++ b/src/coro/Sync.zig @@ -18,6 +18,7 @@ pub const Semaphore = struct { if (Frame.current()) |frame| { if (frame.canceled) return error.Canceled; self.counter += 1; + if (self.counter == 1) return; self.waiters.prepend(&frame.wait_link); defer self.waiters.remove(&frame.wait_link); while (self.counter > 0 and !frame.canceled) Frame.yield(.semaphore);