@@ -147,8 +147,7 @@ pub fn enqueueZcu(q: *Queue, comp: *Compilation, task: ZcuTask) Allocator.Error!
147
147
}
148
148
149
149
fn flushTaskQueue (tid : usize , q : * Queue , comp : * Compilation ) void {
150
- q .flush_safety .lock ();
151
- defer q .flush_safety .unlock ();
150
+ q .flush_safety .lock (); // every `return` site should unlock this before unlocking `q.mutex`
152
151
153
152
if (std .debug .runtime_safety ) {
154
153
q .mutex .lock ();
@@ -167,6 +166,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void {
167
166
} else {
168
167
// We're expecting more prelink tasks so can't move on to ZCU tasks.
169
168
q .state = .finished ;
169
+ q .flush_safety .unlock ();
170
170
return ;
171
171
}
172
172
}
@@ -200,6 +200,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void {
200
200
if (q .wip_zcu .items .len == 0 ) {
201
201
// We've exhausted all available tasks.
202
202
q .state = .finished ;
203
+ q .flush_safety .unlock ();
203
204
return ;
204
205
}
205
206
}
@@ -215,6 +216,7 @@ fn flushTaskQueue(tid: usize, q: *Queue, comp: *Compilation) void {
215
216
if (status_ptr .load (.monotonic ) != .pending ) break :pending ;
216
217
// We will stop for now, and get restarted once this MIR is ready.
217
218
q .state = .{ .wait_for_mir = task .link_func .mir };
219
+ q .flush_safety .unlock ();
218
220
return ;
219
221
}
220
222
link .doZcuTask (comp , tid , task );
0 commit comments