From: Ian Jackson Date: Wed, 29 Jul 2020 22:17:36 +0000 (+0100) Subject: wip destroy etc. X-Git-Tag: otter-0.2.0~1223 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a133a48020692118e90b02987c469a7d9581a9e4;p=otter.git wip destroy etc. --- diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 62137214..7a31ff57 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -231,7 +231,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { execute_for_game(cs, &mut ig, insns, MgmtGameUpdateMode::Bulk) .map_err(|e|{ let name = ig.name.clone(); - Instance::destroy(ig) + Instance::destroy_game(ig) .unwrap_or_else(|e| eprintln!("failed to tidy up failecd creation of {:?}: {:?}", &name, &e)); diff --git a/src/global.rs b/src/global.rs index 25a5a03c..4f75a6f8 100644 --- a/src/global.rs +++ b/src/global.rs @@ -49,7 +49,8 @@ pub struct Client { pub player : PlayerId, } -type DenseSlotMap; +pub type PlayerMap = DenseSlotMap; +/* xxx #[derive(Serialize,Deserialize)] #[repr(transparent)] pub struct PlayerMap(ActualPlayerMap); @@ -60,6 +61,7 @@ impl Deref for PlayerMap { // No DerefMut: callers in this module should access .0 directly // This prevents accidental modification of Players without appropriate // synchrnoisation. +*/ /// UPDATE RELIABILITY/PERSISTENCE RULES /// @@ -252,11 +254,11 @@ impl Instance { .clone() } - #[throws(MgmtError)] + #[throws(ServerFailure)] pub fn destroy_game(mut g: InstanceGuard) { let a_savefile = InstanceGuard::savefile(&g.name, "a-", ""); - let gw = GLOBAL.games.write().unwrap(); + let mut gw = GLOBAL.games.write().unwrap(); fs::remove_file(InstanceGuard::savefile(&g.name, "g-", ""))?; (||{ // Infallible: @@ -264,7 +266,7 @@ impl Instance { gw.remove(&g.name); InstanceGuard::forget_all_tokens(&mut g.tokens_clients); InstanceGuard::forget_all_tokens(&mut g.tokens_players); - }()); // <- No ?, ensures that IEFE is infallible (barring panics) + })(); // <- No ?, ensures that IEFE is infallible (barring panics) (||{ // Best effort: fs::remove_file(&a_savefile)