Send QUIT on exception too. This leads to double QUIT for a usual disconnection, yet is safe. Should fix crashes.
authorunc0rr
Thu, 10 Mar 2011 22:28:40 +0300
changeset 4998 cdcdf37e5532
parent 4997 28c670367e6c
child 4999 a3a09b107652
Send QUIT on exception too. This leads to double QUIT for a usual disconnection, yet is safe. Should fix crashes.
gameServer/Actions.hs
gameServer/ClientIO.hs
gameServer/ServerCore.hs
--- a/gameServer/Actions.hs	Wed Mar 09 22:39:35 2011 +0100
+++ b/gameServer/Actions.hs	Thu Mar 10 22:28:40 2011 +0300
@@ -138,6 +138,8 @@
     put $! s{removedClients = ci `Set.insert` removedClients s}
 
 processAction (DeleteClient ci) = do
+    io $ debugM "Clients"  $ "DeleteClient: " ++ show ci
+
     rnc <- gets roomsClients
     io $ removeClient rnc ci
 
--- a/gameServer/ClientIO.hs	Wed Mar 09 22:39:35 2011 +0100
+++ b/gameServer/ClientIO.hs	Thu Mar 10 22:28:40 2011 +0300
@@ -51,6 +51,8 @@
         msg <- (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show)
         clientOff msg
     `Exception.finally`
+    do
+        clientOff "Connection closed ()"
         remove
     where
         clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg])
--- a/gameServer/ServerCore.hs	Wed Mar 09 22:39:35 2011 +0100
+++ b/gameServer/ServerCore.hs	Thu Mar 10 22:28:40 2011 +0300
@@ -49,8 +49,7 @@
                 put $! as{clientIndex = Just ci}
                 reactCmd cmd
 
-        Remove ci -> do
-            liftIO $ debugM "Clients"  $ "DeleteClient: " ++ show ci
+        Remove ci ->
             processAction (DeleteClient ci)
 
         ClientAccountInfo ci uid info -> do