diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-06-11 02:25:55 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-06-12 17:51:30 +0100 |
| commit | ff89a98c50dbf826564657e7f98cc56194add163 (patch) | |
| tree | 8ea51fc317975bb3fda9e2d014458e5a7e0a0036 /src/link/Queue.zig | |
| parent | 1b27369acbb2009935d49c6906363e8fa425313a (diff) | |
| download | zig-ff89a98c50dbf826564657e7f98cc56194add163.tar.gz zig-ff89a98c50dbf826564657e7f98cc56194add163.zip | |
link.Queue: release safety lock before releasing mutex after stopping
Diffstat (limited to 'src/link/Queue.zig')
| -rw-r--r-- | src/link/Queue.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/link/Queue.zig b/src/link/Queue.zig index ab5fd89699..16ee701771 100644 --- a/src/link/Queue.zig +++ b/src/link/Queue.zig @@ -147,8 +147,7 @@ pub fn enqueueZcu(q: *Queue, comp: *Compilation, task: ZcuTask) Allocator.Error! } fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void { - q.flush_safety.lock(); - defer q.flush_safety.unlock(); + q.flush_safety.lock(); // every `return` site should unlock this before unlocking `q.mutex` if (std.debug.runtime_safety) { q.mutex.lock(); @@ -167,6 +166,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void { } else { // We're expecting more prelink tasks so can't move on to ZCU tasks. q.state = .finished; + q.flush_safety.unlock(); return; } } @@ -200,6 +200,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void { if (q.wip_zcu.items.len == 0) { // We've exhausted all available tasks. q.state = .finished; + q.flush_safety.unlock(); return; } } @@ -215,6 +216,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void { if (status_ptr.load(.monotonic) != .pending) break :pending; // We will stop for now, and get restarted once this MIR is ready. q.state = .{ .wait_for_mir = task.link_func.mir }; + q.flush_safety.unlock(); return; } link.doZcuTask(comp, tid, task); |
