Skip to content

Commit eb4a921

Browse files
committed
Resolve borrow_mut error
1 parent a036a21 commit eb4a921

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/shims/unix/linux/epoll.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,22 +448,25 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
448448
// is not close after the thread unblocks.
449449
let weak_epfd = epfd.downgrade();
450450

451-
let epoll_file_description = epfd
452-
.downcast::<Epoll>()
453-
.ok_or_else(|| err_unsup_format!("non-epoll FD passed to `epoll_wait`"))?;
454-
455-
let binding = epoll_file_description.get_ready_list();
456-
let ready_list = binding.borrow_mut();
451+
// We just need to know if the ready list is empty. The whole logic is wrapped inside a block
452+
// so we don't need to manually drop epfd later.
453+
let ready_list_empty;
454+
{
455+
let epoll_file_description = epfd
456+
.downcast::<Epoll>()
457+
.ok_or_else(|| err_unsup_format!("non-epoll FD passed to `epoll_wait`"))?;
458+
let binding = epoll_file_description.get_ready_list();
459+
ready_list_empty = binding.borrow_mut().is_empty();
460+
}
457461

458-
if ready_list.is_empty() {
462+
if ready_list_empty {
459463
if timeout == 0 {
460464
// Non-blocking with no notification returned.
461465
this.write_scalar(Scalar::from_i32(0), &dest)?;
462466
return Ok(());
463467
} else {
464468
// Blocking
465469
let duration = Duration::from_millis(timeout.into());
466-
drop(ready_list);
467470
this.block_thread(
468471
BlockReason::Epoll,
469472
Some((TimeoutClock::Monotonic, TimeoutAnchor::Relative, duration)),
@@ -488,9 +491,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
488491
}
489492
} else {
490493
// Immediately return epoll notification without blocking.
491-
492-
// Attempt to prevent epfd.borrow_mut in blocking_epoll_callback causing ICE.
493-
drop(ready_list);
494494
this.blocking_epoll_callback(epfd_value, weak_epfd, &dest, &event)?;
495495
return Ok(());
496496
}

0 commit comments

Comments
 (0)