chiark / gitweb /
poison, locks: Ignore all poisoning
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 9 Apr 2021 15:39:44 +0000 (16:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 9 Apr 2021 15:39:44 +0000 (16:39 +0100)
This does more harm than good.  Better to blunder on.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/error.rs
src/global.rs

index c515b3708234e4a95aea9c12a7e8b8c2f429e99f..85202af66c269945717f3c493d94fdbbb19b9270 100644 (file)
@@ -35,8 +35,6 @@ from_instance_lock_error!{OnlineError}
 
 #[derive(Error,Debug)]
 pub enum InternalError {
-  #[error("Game corrupted by previous crash")]
-  GameCorrupted,
   #[error("Accounts file corrupted for acctid={0:?} account={1:?}")]
   AccountsCorrupted(AccountId, Arc<AccountName>),
   #[error("Error saving accounts file: {0}")]
@@ -224,7 +222,6 @@ impl AggregatedIE {
 
 #[derive(Error,Debug)]
 pub enum InstanceLockError {
-  GameCorrupted,
   GameBeingDestroyed,
 }
 #[macro_export]
@@ -235,7 +232,6 @@ macro_rules! from_instance_lock_error {
         use InstanceLockError::*;
         match e {
           GameBeingDestroyed => $into::GameBeingDestroyed,
-          GameCorrupted      => InternalError::GameCorrupted.into(),
         }
       }
     }
index 74cc28e1ef9d24cfa1f8235e4bdc2259732a5299..250947d199c235e58d1cd17a92a5361768f75617 100644 (file)
@@ -3,7 +3,6 @@
 use crate::prelude::*;
 
 use slotmap::dense as sm;
-use std::sync::PoisonError;
 
 // ---------- newtypes and type aliases ----------
 
@@ -238,9 +237,6 @@ struct InstanceSaveAccesses<RawTokenStr, PiecesLoadedRef, OccultIlksRef,
 }
 
 display_as_debug!{InstanceLockError}
-impl<X> From<PoisonError<X>> for InstanceLockError {
-  fn from(_: PoisonError<X>) -> Self { Self::GameCorrupted }
-}
 
 pub struct PrivateCaller(());
 // outsiders cannot construct this
@@ -277,7 +273,7 @@ impl Debug for Instance {
 impl InstanceRef {
   #[throws(InstanceLockError)]
   pub fn lock(&self) -> InstanceGuard<'_> {
-    let c = self.0.lock()?;
+    let c = self.0.lock().unwrap_or_else(|e| e.into_inner());
     if !c.live { throw!(InstanceLockError::GameBeingDestroyed) }
     InstanceGuard { c, gref: self.clone() }
   }