Skip to content

Commit

Permalink
use owned ref for condvar wait
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Nov 10, 2024
1 parent 3316da7 commit bce251c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/concurrency/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn condvar_wait(
&mut self,
condvar: CondvarId,
mutex_ref: &MutexRef,
mutex_ref: MutexRef,
timeout: Option<(TimeoutClock, TimeoutAnchor, Duration)>,
retval_succ: Scalar,
retval_timeout: Scalar,
dest: MPlaceTy<'tcx>,
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
if let Some(old_locked_count) = this.mutex_unlock(mutex_ref)? {
if let Some(old_locked_count) = this.mutex_unlock(&mutex_ref)? {
if old_locked_count != 1 {
throw_unsup_format!(
"awaiting a condvar on a mutex acquired multiple times is not supported"
Expand All @@ -651,7 +651,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let thread = this.active_thread();
let waiters = &mut this.machine.sync.condvars[condvar].waiters;
waiters.push_back(thread);
let mutex_ref = mutex_ref.clone();
this.block_thread(
BlockReason::Condvar(condvar),
timeout,
Expand Down
4 changes: 2 additions & 2 deletions src/shims/unix/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

this.condvar_wait(
data.id,
&mutex_ref,
mutex_ref,
None, // no timeout
Scalar::from_i32(0),
Scalar::from_i32(0), // retval_timeout -- unused
Expand Down Expand Up @@ -871,7 +871,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

this.condvar_wait(
data.id,
&mutex_ref,
mutex_ref,
Some((timeout_clock, TimeoutAnchor::Absolute, duration)),
Scalar::from_i32(0),
this.eval_libc("ETIMEDOUT"), // retval_timeout
Expand Down

0 comments on commit bce251c

Please sign in to comment.