equal
deleted
inserted
replaced
87 pipeDbConnectionLoop queries cChan hIn hOut updatedCache newReq |
87 pipeDbConnectionLoop queries cChan hIn hOut updatedCache newReq |
88 where |
88 where |
89 maybeException (Just a) = return a |
89 maybeException (Just a) = return a |
90 maybeException Nothing = ioError (userError "Can't read") |
90 maybeException Nothing = ioError (userError "Can't read") |
91 |
91 |
92 pipeDbConnection :: forall a b. |
92 pipeDbConnection :: |
93 (Num a, Ord a) => |
|
94 Map.Map ByteString (UTCTime, AccountInfo) |
93 Map.Map ByteString (UTCTime, AccountInfo) |
95 -> ServerInfo |
94 -> ServerInfo |
96 -> a |
95 -> Int |
97 -> IO b |
96 -> IO () |
98 |
97 |
99 pipeDbConnection accountsCache si errNum = do |
98 pipeDbConnection accountsCache si errNum = do |
100 (updatedCache, newErrNum) <- |
99 (updatedCache, newErrNum) <- |
101 Exception.handle (\(e :: Exception.IOException) -> warningM "Database" (show e) >> return (accountsCache, errNum + 1)) $ do |
100 Exception.handle (\(e :: Exception.IOException) -> warningM "Database" (show e) >> return (accountsCache, errNum + 1)) $ do |
102 (Just hIn, Just hOut, _, _) <- createProcess (proc "./OfficialServer/extdbinterface" []) |
101 (Just hIn, Just hOut, _, _) <- createProcess (proc "./OfficialServer/extdbinterface" []) |
114 |
113 |
115 when (newErrNum > 1) $ flushRequests si |
114 when (newErrNum > 1) $ flushRequests si |
116 threadDelay (3000000) |
115 threadDelay (3000000) |
117 pipeDbConnection updatedCache si newErrNum |
116 pipeDbConnection updatedCache si newErrNum |
118 |
117 |
119 dbConnectionLoop :: forall b. ServerInfo -> IO b |
118 dbConnectionLoop :: ServerInfo -> IO () |
120 dbConnectionLoop si = |
119 dbConnectionLoop si = |
121 if (not . B.null $ dbHost si) then |
120 if (not . B.null $ dbHost si) then |
122 pipeDbConnection Map.empty si 0 |
121 pipeDbConnection Map.empty si 0 |
123 else |
122 else |
124 fakeDbConnection si |
123 fakeDbConnection si |