mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-19 07:31:55 +01:00
Remove Hoogle lock
This commit is contained in:
parent
68fa14a4bb
commit
3d8cd6a115
@ -160,7 +160,6 @@ withFoundation appLogFunc appSettings inner = do
|
|||||||
\oldMatcher -> getLatestMatcher appHttpManager `catchAny` \e -> do
|
\oldMatcher -> getLatestMatcher appHttpManager `catchAny` \e -> do
|
||||||
runRIO appLogFunc $ RIO.logError $ "Couldn't get Stack matcher: " <> displayShow e
|
runRIO appLogFunc $ RIO.logError $ "Couldn't get Stack matcher: " <> displayShow e
|
||||||
pure oldMatcher
|
pure oldMatcher
|
||||||
appHoogleLock <- newMVar ()
|
|
||||||
appMirrorStatus <- mkUpdateMirrorStatus
|
appMirrorStatus <- mkUpdateMirrorStatus
|
||||||
hoogleLocker <- newHoogleLocker appLogFunc appHttpManager
|
hoogleLocker <- newHoogleLocker appLogFunc appHttpManager
|
||||||
let appGetHoogleDB = singleRun hoogleLocker
|
let appGetHoogleDB = singleRun hoogleLocker
|
||||||
|
|||||||
@ -35,9 +35,6 @@ data App = App
|
|||||||
, appStackageDatabase :: !StackageDatabase
|
, appStackageDatabase :: !StackageDatabase
|
||||||
, appLatestStackMatcher :: !(IO (Text -> Maybe Text))
|
, appLatestStackMatcher :: !(IO (Text -> Maybe Text))
|
||||||
-- ^ Give a pattern, get a URL
|
-- ^ Give a pattern, get a URL
|
||||||
, appHoogleLock :: !(MVar ())
|
|
||||||
-- ^ Avoid concurrent Hoogle queries, see
|
|
||||||
-- https://github.com/fpco/stackage-server/issues/172
|
|
||||||
, appMirrorStatus :: !(IO (Status, WidgetFor App ()))
|
, appMirrorStatus :: !(IO (Status, WidgetFor App ()))
|
||||||
, appGetHoogleDB :: !(SnapName -> IO (Maybe FilePath))
|
, appGetHoogleDB :: !(SnapName -> IO (Maybe FilePath))
|
||||||
, appGitRev :: !GitRev
|
, appGitRev :: !GitRev
|
||||||
|
|||||||
@ -47,9 +47,6 @@ getHoogleR name0 = track "Handler.Hoogle.getHoogleR" do
|
|||||||
mdatabasePath <- getHoogleDB name
|
mdatabasePath <- getHoogleDB name
|
||||||
dbPath <- maybe (hoogleDatabaseNotAvailableFor name) return mdatabasePath
|
dbPath <- maybe (hoogleDatabaseNotAvailableFor name) return mdatabasePath
|
||||||
|
|
||||||
-- Avoid concurrent Hoogle queries, see
|
|
||||||
-- https://github.com/fpco/stackage-server/issues/172
|
|
||||||
lock <- appHoogleLock <$> getYesod
|
|
||||||
urlRender <- getUrlRender
|
urlRender <- getUrlRender
|
||||||
HoogleQueryOutput results mtotalCount <-
|
HoogleQueryOutput results mtotalCount <-
|
||||||
case mquery of
|
case mquery of
|
||||||
@ -64,9 +61,7 @@ getHoogleR name0 = track "Handler.Hoogle.getHoogleR" do
|
|||||||
, hqiExact = exact
|
, hqiExact = exact
|
||||||
}
|
}
|
||||||
|
|
||||||
liftIO $ withMVar lock
|
liftIO $ Hoogle.withDatabase dbPath
|
||||||
$ const
|
|
||||||
$ Hoogle.withDatabase dbPath
|
|
||||||
-- NB! I got a segfault when I didn't force with $!
|
-- NB! I got a segfault when I didn't force with $!
|
||||||
$ \db -> return $! runHoogleQuery urlRender name db input
|
$ \db -> return $! runHoogleQuery urlRender name db input
|
||||||
Nothing -> return $ HoogleQueryOutput [] Nothing
|
Nothing -> return $ HoogleQueryOutput [] Nothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user