# HG changeset patch # User unc0rr # Date 1298475247 -10800 # Node ID 84543ecae8c3b24fa6f8aa97cccdda8d2c2343d6 # Parent df752b69a142040126c5c9a03fb4e59ebb0a4abe Don't forkIO main loop diff -r df752b69a142 -r 84543ecae8c3 gameServer/Actions.hs --- a/gameServer/Actions.hs Sat Feb 19 04:04:34 2011 +0100 +++ b/gameServer/Actions.hs Wed Feb 23 18:34:07 2011 +0300 @@ -53,6 +53,7 @@ | StatsAction | RestartServer Bool + type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action] instance NFData Action where @@ -412,5 +413,8 @@ where st irnc = (length $ allRooms irnc, length $ allClients irnc) -processAction (RestartServer _) = - return () \ No newline at end of file +processAction (RestartServer force) = do + if force then do + return () + else + processAction $ ModifyServerInfo (\s -> s{restartPending=True}) diff -r df752b69a142 -r 84543ecae8c3 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Sat Feb 19 04:04:34 2011 +0100 +++ b/gameServer/CoreTypes.hs Wed Feb 23 18:34:07 2011 +0300 @@ -135,6 +135,7 @@ dbLogin :: B.ByteString, dbPassword :: B.ByteString, lastLogins :: [(B.ByteString, (UTCTime, B.ByteString))], + restartPending :: Bool, stats :: TMVar StatisticsInfo, coreChan :: Chan CoreMessage, dbQueries :: Chan DBQuery @@ -156,6 +157,7 @@ "" "" [] + False data AccountInfo = HasAccount B.ByteString Bool diff -r df752b69a142 -r 84543ecae8c3 gameServer/ServerCore.hs --- a/gameServer/ServerCore.hs Sat Feb 19 04:04:34 2011 +0100 +++ b/gameServer/ServerCore.hs Wed Feb 23 18:34:07 2011 +0300 @@ -32,7 +32,7 @@ mainLoop :: StateT ServerState IO () mainLoop = forever $ do - get >>= \s -> put $! s + -- get >>= \s -> put $! s si <- gets serverInfo r <- liftIO $ readChan $ coreChan si @@ -53,11 +53,6 @@ liftIO $ debugM "Clients" $ "DeleteClient: " ++ show ci processAction (DeleteClient ci) - --else - --do - --debugM "Clients" "Message from dead client" - --return (serverInfo, rnc) - ClientAccountInfo ci uid info -> do rnc <- gets roomsClients exists <- liftIO $ clientExists rnc ci @@ -90,6 +85,4 @@ rnc <- newRoomsAndClients newRoom - _ <- forkIO $ evalStateT mainLoop (ServerState Nothing si Set.empty rnc) - - forever $ threadDelay 3600000000 -- one hour + evalStateT mainLoop (ServerState Nothing si Set.empty rnc)