Remove thread_id from epoll::thread_ids after timeout
This commit is contained in:
parent
a4d7564219
commit
7e8ca571d0
2 changed files with 9 additions and 13 deletions
|
|
@ -578,10 +578,6 @@ impl<'tcx> ThreadManager<'tcx> {
|
|||
self.threads[thread_id].state.is_terminated()
|
||||
}
|
||||
|
||||
fn has_blocked_on_epoll(&self, thread_id: ThreadId) -> bool {
|
||||
self.threads[thread_id].state.is_blocked_on(BlockReason::Epoll)
|
||||
}
|
||||
|
||||
/// Have all threads terminated?
|
||||
fn have_all_terminated(&self) -> bool {
|
||||
self.threads.iter().all(|thread| thread.state.is_terminated())
|
||||
|
|
@ -1141,12 +1137,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
this.machine.threads.enable_thread(thread_id);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_blocked_on_epoll(&self, thread_id: ThreadId) -> bool {
|
||||
let this = self.eval_context_ref();
|
||||
this.machine.threads.has_blocked_on_epoll(thread_id)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn active_thread_stack<'a>(&'a self) -> &'a [Frame<'tcx, Provenance, FrameExtra<'tcx>>] {
|
||||
let this = self.eval_context_ref();
|
||||
|
|
|
|||
|
|
@ -509,6 +509,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
}
|
||||
@timeout = |this| {
|
||||
// No notification after blocking timeout.
|
||||
let Some(epfd) = weak_epfd.upgrade() else {
|
||||
throw_unsup_format!("epoll FD {epfd_value} got closed while blocking.")
|
||||
};
|
||||
// Remove the current active thread_id from the blocked thread_id list.
|
||||
epfd.downcast::<Epoll>()
|
||||
.ok_or_else(|| err_unsup_format!("non-epoll FD passed to `epoll_wait`"))?
|
||||
.thread_id.borrow_mut()
|
||||
.retain(|&id| id != this.active_thread());
|
||||
this.write_int(0, &dest)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -605,9 +613,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
waiter.sort();
|
||||
waiter.dedup();
|
||||
for thread_id in waiter {
|
||||
if this.has_blocked_on_epoll(thread_id) {
|
||||
this.unblock_thread(thread_id, BlockReason::Epoll)?;
|
||||
}
|
||||
this.unblock_thread(thread_id, BlockReason::Epoll)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue