--- a/gameServer/ClientIO.hs Wed Jun 27 16:40:36 2012 -0400
+++ b/gameServer/ClientIO.hs Thu Jun 28 22:45:06 2012 +0400
@@ -43,16 +43,18 @@
clientRecvLoop :: Socket -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> (forall a. IO a -> IO a) -> IO ()
clientRecvLoop s chan clChan ci restore =
- myThreadId >>=
+ (myThreadId >>=
\t -> (restore $ forkIO (clientSendLoop s t clChan ci) >>
listenLoop s chan ci >> return "Connection closed")
+ `Exception.catch` (\(e :: ShutdownThreadException) -> return . B.pack . show $ e)
`Exception.catch` (\(e :: Exception.IOException) -> return . B.pack . show $ e)
- `Exception.catch` (\(e :: ShutdownThreadException) -> return . B.pack . show $ e)
`Exception.catch` (\(e :: Exception.SomeException) -> return . B.pack . show $ e)
- >>= clientOff >> remove
+ >>= clientOff) `Exception.finally` remove
where
clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg])
- remove = writeChan chan $ Remove ci
+ remove = do
+ clientOff "Client is in some weird state"
+ writeChan chan $ Remove ci