# HG changeset patch
# User unc0rr
# Date 1343762940 -14400
# Node ID c2dcf97ca664bbec32a23b1f1279bcfdac6a84bf
# Parent  9cc5a25869783511437023b0934bc228581679ab
Okay, this is workaround over ping timeouts problem on the server. Could make server crash if recieve thread wakes up after second ping timeout event.

diff -r 9cc5a2586978 -r c2dcf97ca664 gameServer/Actions.hs
--- a/gameServer/Actions.hs	Fri Jul 27 23:16:30 2012 -0400
+++ b/gameServer/Actions.hs	Tue Jul 31 23:29:00 2012 +0400
@@ -146,9 +146,14 @@
     io $
         infoM "Clients" (show ci ++ " quits: " ++ B.unpack msg)
 
-    processAction $ AnswerClients [chan] ["BYE", msg]
     when loggedIn $ processAction $ AnswerClients clientsChans ["LOBBY:LEFT", clNick, msg]
 
+    mapM processAction
+        [
+        AnswerClients [chan] ["BYE", msg]
+        , ModifyClient (\c -> c{logonPassed = False}) -- this will effectively hide client from others while he isn't deleted from list
+        ]
+
     s <- get
     put $! s{removedClients = ci `Set.insert` removedClients s}
 
@@ -522,9 +527,11 @@
     where
         kickTimeouted rnc ci = do
             pq <- io $ client'sM rnc pingsQueue ci
-            when (pq > 0) $
+            when (pq > 0) $ do
                 withStateT (\as -> as{clientIndex = Just ci}) $
                     processAction (ByeClient "Ping timeout")
+                when (pq > 1) $
+                    processAction $ DeleteClient ci -- smth went wrong with client io threads, issue DeleteClient here
 
 
 processAction StatsAction = do