# HG changeset patch # User unc0rr # Date 1299697889 -10800 # Node ID 76ef3d8bd78e5c4610bea25013e6153037ab9c50 # Parent d3ca68e4860eb717a3b025e6e62a63e750d6fdbd Fix crash (accessing already deleted client record) by reverting to old client removing handling + throwTo diff -r d3ca68e4860e -r 76ef3d8bd78e gameServer/ClientIO.hs --- a/gameServer/ClientIO.hs Wed Mar 09 21:41:16 2011 +0300 +++ b/gameServer/ClientIO.hs Wed Mar 09 22:11:29 2011 +0300 @@ -45,13 +45,16 @@ sendPacket packet = writeChan chan $ ClientMessage (ci, packet) - clientRecvLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO () -clientRecvLoop s chan ci = do - msg <- (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show) - clientOff msg +clientRecvLoop s chan ci = + do + msg <- (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show) + clientOff msg + `Exception.finally` + remove where clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg]) + remove = writeChan chan $ Remove ci @@ -65,8 +68,7 @@ if isQuit answer then do Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s - killThread tId - writeChan cChan $ Remove ci + Exception.throwTo tId ShutdownThreadException else clientSendLoop s tId cChan chan ci diff -r d3ca68e4860e -r 76ef3d8bd78e gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Wed Mar 09 21:41:16 2011 +0300 +++ b/gameServer/CoreTypes.hs Wed Mar 09 22:11:29 2011 +0300 @@ -205,3 +205,8 @@ deriving (Show, Typeable) instance Exception ShutdownException + +data ShutdownThreadException = ShutdownThreadException + deriving (Show, Typeable) + +instance Exception ShutdownThreadException diff -r d3ca68e4860e -r 76ef3d8bd78e gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Wed Mar 09 21:41:16 2011 +0300 +++ b/gameServer/OfficialServer/DBInteraction.hs Wed Mar 09 22:11:29 2011 +0300 @@ -36,7 +36,8 @@ ClearCache -> return () SendStats {} -> return () ---dbConnectionLoop :: forall b. (ServerInfo c) -> IO b +dbConnectionLoop :: ServerInfo -> IO () + #if defined(OFFICIAL_SERVER) flushRequests :: ServerInfo -> IO () flushRequests si = do @@ -115,7 +116,6 @@ threadDelay (3000000) pipeDbConnection updatedCache si newErrNum -dbConnectionLoop :: ServerInfo -> IO () dbConnectionLoop si = if (not . B.null $ dbHost si) then pipeDbConnection Map.empty si 0