]> git.lizzy.rs Git - rust.git/commitdiff
make mutex_unlock infallible
authorRalf Jung <post@ralfj.de>
Sat, 30 May 2020 20:54:37 +0000 (22:54 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 30 May 2020 20:54:37 +0000 (22:54 +0200)
src/shims/sync.rs
src/sync.rs

index 39a087dc9ac2c31160d82a9f56b0ea02fa674176..8986455a14fcdad1c487c92c35ccac44dc1c4174 100644 (file)
@@ -316,7 +316,7 @@ fn release_cond_mutex_and_block<'mir, 'tcx: 'mir>(
     active_thread: ThreadId,
     mutex: MutexId,
 ) -> InterpResult<'tcx> {
-    if let Some(old_locked_count) = ecx.mutex_unlock(mutex, active_thread)? {
+    if let Some(old_locked_count) = ecx.mutex_unlock(mutex, active_thread) {
         if old_locked_count != 1 {
             throw_unsup_format!("awaiting on a lock acquired multiple times is not supported");
         }
@@ -486,7 +486,7 @@ fn pthread_mutex_unlock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'t
         let id = mutex_get_or_create_id(this, mutex_op)?;
         let active_thread = this.get_active_thread();
 
-        if let Some(_old_locked_count) = this.mutex_unlock(id, active_thread)? {
+        if let Some(_old_locked_count) = this.mutex_unlock(id, active_thread) {
             // The mutex was locked by the current thread.
             Ok(0)
         } else {
index 5ba29b5afa252e349a2e9a9d44c11655d3d47282..0d4b4d6b7c1cb1b57a3f364a570bb85dd6453c58 100644 (file)
@@ -153,14 +153,14 @@ fn mutex_unlock(
         &mut self,
         id: MutexId,
         expected_owner: ThreadId,
-    ) -> InterpResult<'tcx, Option<usize>> {
+    ) -> Option<usize> {
         let this = self.eval_context_mut();
         let mutex = &mut this.machine.threads.sync.mutexes[id];
         if let Some(current_owner) = mutex.owner {
             // Mutex is locked.
             if current_owner != expected_owner {
                 // Only the owner can unlock the mutex.
-                return Ok(None);
+                return None;
             }
             let old_lock_count = mutex.lock_count;
             mutex.lock_count = old_lock_count
@@ -172,10 +172,10 @@ fn mutex_unlock(
                 // to another thread.
                 this.mutex_dequeue_and_lock(id);
             }
-            Ok(Some(old_lock_count))
+            Some(old_lock_count)
         } else {
             // Mutex is unlocked.
-            Ok(None)
+            None
         }
     }