chiark / gitweb /
wip destroy etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 29 Jul 2020 22:17:36 +0000 (23:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 29 Jul 2020 22:17:36 +0000 (23:17 +0100)
src/cmdlistener.rs
src/global.rs

index 62137214827a83d47ba4aacb414642bddad8a157..7a31ff57926ac25a593e224e34d636fb425ddd5f 100644 (file)
@@ -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));
index 25a5a03c4505a94c68d47efa1b51fd8bab199fc5..4f75a6f8a170bdc1c1d1f29ca9a9e442486a7ae8 100644 (file)
@@ -49,7 +49,8 @@ pub struct Client {
   pub player : PlayerId,
 }
 
-type DenseSlotMap<PlayerId,PlayerState>;
+pub type PlayerMap = DenseSlotMap<PlayerId,PlayerState>;
+/* 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)