From 371ce26ec7b647ed9ce7ca15e66961f3fbb8279e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 9 Apr 2021 16:45:29 +0100 Subject: [PATCH] poison, locks: Rename lock_even_poisoned Actually, this just checks for liveness now. Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 4 ++-- src/global.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index aaf002f0..1e2b8368 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -204,7 +204,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { }; let mut names = names.into_iter().map(|name| { let gref = Instance::lookup_by_name_unauth(&name)?; - let mut igu = gref.lock_even_poisoned(); + let mut igu = gref.lock_even_destroying(); let _ig = if let Some(auth_all) = auth_all { igu.by_ref(auth_all) } else { @@ -234,7 +234,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { let mut games = games_lock(); let auth = authorise_by_account(cs, &mut ag, &game)?; let gref = Instance::lookup_by_name_locked(&games, &game, auth)?; - let ig = gref.lock_even_poisoned(); + let ig = gref.lock_even_destroying(); Instance::destroy_game(&mut games, ig, auth)?; Fine } diff --git a/src/global.rs b/src/global.rs index 250947d1..0e414938 100644 --- a/src/global.rs +++ b/src/global.rs @@ -278,7 +278,7 @@ impl InstanceRef { InstanceGuard { c, gref: self.clone() } } - pub fn lock_even_poisoned(&self) -> MutexGuard { + pub fn lock_even_destroying(&self) -> MutexGuard { match self.0.lock() { Ok(g) => g, Err(poison) => poison.into_inner(), @@ -303,10 +303,10 @@ impl Unauthorised { Unauthorised::of(must_not_escape.lock()?) } - pub fn lock_even_poisoned<'r>(&'r self) -> Unauthorised, A> { + pub fn lock_even_destroying<'r>(&'r self) -> Unauthorised, A> { let must_not_escape = self.by_ref(Authorisation::authorise_any()); Unauthorised::of(InstanceGuard { - c: must_not_escape.lock_even_poisoned(), + c: must_not_escape.lock_even_destroying(), gref: must_not_escape.clone(), }) } @@ -1281,7 +1281,7 @@ pub fn process_all_players_for_account< (games: &mut GamesGuard, acctid: AccountId, mut f: F) { for gref in games.values() { - let c = gref.lock_even_poisoned(); + let c = gref.lock_even_destroying(); let remove: Vec<_> = c.g.iplayers.iter().filter_map(|(player,pr)| { if pr.ipl.acctid == acctid { Some(player) } else { None } }).collect(); @@ -1400,7 +1400,7 @@ fn client_expire_old_clients() { type Ret; fn iter<'g>(&mut self, gref: &'g InstanceRef, max_age: Instant) -> (MutexGuard<'g, InstanceContainer>, Option) { - let c = gref.lock_even_poisoned(); + let c = gref.lock_even_destroying(); let ret = 'ret: loop { for (client, cl) in &c.g.clients { if cl.lastseen > max_age { continue } @@ -1462,14 +1462,14 @@ fn global_expire_old_logs() { let read = GLOBAL.games_table.read().unwrap(); for gref in read.values() { - if gref.lock_even_poisoned().g.gs.want_expire_some_logs(cutoff) { + if gref.lock_even_destroying().g.gs.want_expire_some_logs(cutoff) { want_expire.push(gref.clone()) } } drop(read); for gref in want_expire.drain(..) { - let mut g = gref.lock_even_poisoned(); + let mut g = gref.lock_even_destroying(); info!("expiring old log entries in {:?}", &g.g.name); g.g.gs.do_expire_old_logs(cutoff); } -- 2.30.2