gameServer/OfficialServer/DBInteraction.hs
changeset 2296 19f2f76dc346
parent 2245 c011aecc95e5
child 2306 1addfe9fddb1
equal deleted inserted replaced
2295:2fff3e4ce52f 2296:19f2f76dc346
     6 
     6 
     7 import Prelude hiding (catch);
     7 import Prelude hiding (catch);
     8 import System.Process
     8 import System.Process
     9 import System.IO
     9 import System.IO
    10 import Control.Concurrent
    10 import Control.Concurrent
    11 import Control.Exception
    11 #if defined(NEW_EXCEPTIONS)
       
    12 import qualified Control.OldException as Exception
       
    13 #else
       
    14 import qualified Control.Exception as Exception
       
    15 #endif
    12 import Control.Monad
    16 import Control.Monad
    13 import qualified Data.Map as Map
    17 import qualified Data.Map as Map
    14 import Monad
    18 import Monad
    15 import Maybe
    19 import Maybe
    16 import System.Log.Logger
    20 import System.Log.Logger
    42 -- to be deleted --------------------------------------------------
    46 -- to be deleted --------------------------------------------------
    43 -------------------------------------------------------------------
    47 -------------------------------------------------------------------
    44 
    48 
    45 
    49 
    46 pipeDbConnectionLoop queries coreChan hIn hOut accountsCache =
    50 pipeDbConnectionLoop queries coreChan hIn hOut accountsCache =
    47 	Control.Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $
    51 	Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $
    48 	do
    52 	do
    49 	q <- readChan queries
    53 	q <- readChan queries
    50 	updatedCache <- case q of
    54 	updatedCache <- case q of
    51 		CheckAccount clUid clNick _ -> do
    55 		CheckAccount clUid clNick _ -> do
    52 			let cacheEntry = clNick `Map.lookup` accountsCache
    56 			let cacheEntry = clNick `Map.lookup` accountsCache
    81 		maybeException Nothing = ioError (userError "Can't read")
    85 		maybeException Nothing = ioError (userError "Can't read")
    82 
    86 
    83 
    87 
    84 pipeDbConnection accountsCache serverInfo = do
    88 pipeDbConnection accountsCache serverInfo = do
    85 	updatedCache <-
    89 	updatedCache <-
    86 		Control.Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $ do
    90 		Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $ do
    87 			(Just hIn, Just hOut, _, _) <- createProcess (proc "./OfficialServer/extdbinterface" [])
    91 			(Just hIn, Just hOut, _, _) <- createProcess (proc "./OfficialServer/extdbinterface" [])
    88 					{std_in = CreatePipe,
    92 					{std_in = CreatePipe,
    89 					std_out = CreatePipe}
    93 					std_out = CreatePipe}
    90 			hSetBuffering hIn LineBuffering
    94 			hSetBuffering hIn LineBuffering
    91 			hSetBuffering hOut LineBuffering
    95 			hSetBuffering hOut LineBuffering