My best guess for issue #285 is send thread being stuck at sendAll function, so I move client removing function before sendAll
authorunc0rr
Thu, 22 Sep 2011 11:44:39 +0400
changeset 5989 23407ecb1826
parent 5988 d08565e2a7d7
child 5990 578978418fe5
My best guess for issue #285 is send thread being stuck at sendAll function, so I move client removing function before sendAll
gameServer/ClientIO.hs
--- a/gameServer/ClientIO.hs	Wed Sep 21 22:03:31 2011 -0400
+++ b/gameServer/ClientIO.hs	Thu Sep 22 11:44:39 2011 +0400
@@ -58,6 +58,10 @@
 clientSendLoop :: Socket -> ThreadId -> Chan [B.ByteString] -> ClientIndex -> IO ()
 clientSendLoop s tId chan ci = do
     answer <- readChan chan
+
+    when (isQuit answer) $
+        killReciever . B.unpack $ quitMessage answer
+
     Exception.handle
         (\(e :: Exception.IOException) -> unless (isQuit answer) . killReciever $ show e) $
             sendAll s $ B.unlines answer `B.snoc` '\n'
@@ -65,7 +69,6 @@
     if isQuit answer then
         do
         Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s
-        killReciever . B.unpack $ quitMessage answer
         else
         clientSendLoop s tId chan ci