AI masks: the worker stops counting a job as pending before it replies
The pending counter was decremented when the job's guard dropped at the end of the loop iteration, after the reply was sent, so a waiting caller (CLI / MCP mask.add) could see the segmenter still busy right after its answer arrived. Under a loaded test run that made tests_segment::waiting_requests_with_a_damaged_model_are_errors fail on assert!(!busy()). The guard is now dropped just before each reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01912WaK6Rmew3wxZuPyX7E8
This commit is contained in:
parent
2472021091
commit
6ea9b979c8
|
|
@ -210,8 +210,11 @@ fn run(rx: &mpsc::Receiver<Job>, shared: &Shared, idle: Duration) {
|
|||
}
|
||||
let Some(mut job) = queue.pop_front() else { continue };
|
||||
let is_detail = matches!(job.kind, Kind::Detail { .. });
|
||||
let _done = Done(if is_detail { &shared.detail } else { &shared.pending });
|
||||
// counts the job as pending until just before its reply goes out: a caller woken by the
|
||||
// reply must not still see the worker busy with it
|
||||
let done = Done(if is_detail { &shared.detail } else { &shared.pending });
|
||||
if queue.iter().any(|later| supersedes(later, &job)) {
|
||||
drop(done);
|
||||
let _ = job.reply.send(Outcome { tag: job.tag, result: Ok(None), superseded: true });
|
||||
continue;
|
||||
}
|
||||
|
|
@ -229,6 +232,7 @@ fn run(rx: &mpsc::Receiver<Job>, shared: &Shared, idle: Duration) {
|
|||
state.cache = None;
|
||||
}
|
||||
shared.loaded.store(state.model.is_some(), Ordering::SeqCst);
|
||||
drop(done);
|
||||
let _ = job.reply.send(Outcome { tag: job.tag, result, superseded: false });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue