Skip to content

Commit

Permalink
coro.Semaphore: fix infinite waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
YiraSan authored and Cloudef committed Nov 13, 2024
1 parent 2b91534 commit 9c3873b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/coro/Sync.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9c3873b

Please sign in to comment.