gameServer/OfficialServer/DBInteraction.hs
changeset 4982 3572eaf14340
parent 4975 31da8979e5b1
child 4989 4771fed9272e
--- a/gameServer/OfficialServer/DBInteraction.hs	Fri Mar 04 11:30:53 2011 +0300
+++ b/gameServer/OfficialServer/DBInteraction.hs	Fri Mar 04 22:45:28 2011 +0300
@@ -27,7 +27,7 @@
 localAddressList :: [B.ByteString]
 localAddressList = ["127.0.0.1", "0:0:0:0:0:0:0:1", "0:0:0:0:0:ffff:7f00:1"]
 
---fakeDbConnection :: forall b. (ServerInfo c)-> IO b
+fakeDbConnection :: forall b c. ServerInfo c -> IO b
 fakeDbConnection si = forever $ do
     q <- readChan $ dbQueries si
     case q of
@@ -89,7 +89,13 @@
         maybeException (Just a) = return a
         maybeException Nothing = ioError (userError "Can't read")
 
---pipeDbConnection :: forall b. Map.Map ByteString (UTCTime, AccountInfo) -> (ServerInfo c) -> Int -> IO b
+pipeDbConnection :: forall a c b.
+        (Num a, Ord a) =>
+        Map.Map ByteString (UTCTime, AccountInfo)
+        -> ServerInfo c
+        -> a
+        -> IO b
+
 pipeDbConnection accountsCache si errNum = do
     (updatedCache, newErrNum) <-
         Exception.handle (\(e :: Exception.IOException) -> warningM "Database" (show e) >> return (accountsCache, errNum + 1)) $ do
@@ -100,6 +106,7 @@
             hSetBuffering hOut LineBuffering
 
             B.hPutStrLn hIn $ dbHost si
+            B.hPutStrLn hIn $ dbName si
             B.hPutStrLn hIn $ dbLogin si
             B.hPutStrLn hIn $ dbPassword si
             (c, r) <- pipeDbConnectionLoop (dbQueries si) (coreChan si) hIn hOut accountsCache 0
@@ -109,6 +116,7 @@
     threadDelay (3000000)
     pipeDbConnection updatedCache si newErrNum
 
+dbConnectionLoop :: forall c b. ServerInfo c -> IO b
 dbConnectionLoop si =
         if (not . B.null $ dbHost si) then
             pipeDbConnection Map.empty si 0