From: Ian Jackson Date: Sun, 1 Nov 2020 22:32:37 +0000 (+0000) Subject: wip errors from introducing accounts X-Git-Tag: otter-0.2.0~567 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b2a969782c5ee0f9a5f2c75c2f7f316f174f2e69;p=otter.git wip errors from introducing accounts Signed-off-by: Ian Jackson --- diff --git a/src/accounts.rs b/src/accounts.rs index 62454bac..9c9c7370 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -273,8 +273,10 @@ impl AccountsGuard { let (entry, acctid) = self.lookup_mut_caller_must_save(key, auth)?; if let Some(new_access) = set_access { - process_all_players_for_account(acctid, - InstanceGuard::invalidate_tokens)?; + process_all_players_for_account( + acctid, + |ig, player| ig.invalidate_tokens(player) + )?; entry.access = AccessRecord(new_access); } let output = f(&mut *entry, acctid); diff --git a/src/global.rs b/src/global.rs index 10c34a85..28b22f4c 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1108,11 +1108,10 @@ pub fn record_token ( #[throws(E)] pub fn process_all_players_for_account< - 'i, 'j : 'i, E: Error, - F: FnMut(&'i mut InstanceGuard<'j>, PlayerId) -> Result<(),E> + F: FnMut(&mut InstanceGuard<'_>, PlayerId) -> Result<(),E> > - (acctid: AccountId, f: F) + (acctid: AccountId, mut f: F) { let games = GLOBAL.games.write().unwrap(); for gref in games.values() { @@ -1120,8 +1119,8 @@ pub fn process_all_players_for_account< let remove : Vec<_> = c.g.iplayers.iter().filter_map(|(player,pr)| { if pr.ipl.acctid == acctid { Some(player) } else { None } }).collect(); - let ig = InstanceGuard { gref: gref.clone(), c }; - for player in remove.drain(..) { + let mut ig = InstanceGuard { gref: gref.clone(), c }; + for player in remove.into_iter() { f(&mut ig, player)?; } }