on master help sign in
defining settingsFileInfoCacheDuration.
commitaa4ad3a946e497ecdcc6060a0959a4bffd7e878a authorKazu Yamamoto <kazu@iij.ad.jp> dateMon 30 Nov 2015, 17:24 (11 years ago) parent2ccadb9
3 files changed+8−1
warp/Network/Wai/Handler/Warp.hs+4 warp/Network/Wai/Handler/Warp/Run.hs+2−1 warp/Network/Wai/Handler/Warp/Settings.hs+2
warp/Network/Wai/Handler/Warp.hs+4
@@ -66,6 +66,7 @@ module Network.Wai.Handler.Warp (
6666 , setTimeout
6767 , setManager
6868 , setFdCacheDuration
69+ , setFileInfoCacheDuration
6970 , setBeforeMainLoop
7071 , setNoParsePath
7172 , setInstallShutdownHandler
@@ -226,6 +227,9 @@ setManager x y = y { settingsManager = Just x }
226227setFdCacheDuration :: Int -> Settings -> Settings
227228setFdCacheDuration x y = y { settingsFdCacheDuration = x }
228229
230+setFileInfoCacheDuration :: Int -> Settings -> Settings
231+setFileInfoCacheDuration x y = y { settingsFileInfoCacheDuration = x }
232+
229233-- | Code to run after the listening socket is ready but before entering
230234-- the main event loop. Useful for signaling to tests that they can start
231235-- running, or to drop permissions after binding to a restricted port.
warp/Network/Wai/Handler/Warp/Run.hs+2−1
@@ -243,12 +243,13 @@ runServeSettingsConnectionMakerSecure set getConnMaker serveConn = do
243243 withII action =
244244 D.withDateCache $ \dc ->
245245 F.withFdCache fdCacheDurationInSeconds $ \fc ->
246− I.withFileInfoCache 10 $ \get -> -- fixme: hard-coding
246+ I.withFileInfoCache fdFileInfoDurationInSeconds $ \get ->
247247 withTimeoutManager $ \tm -> do
248248 let ii0 = InternalInfo undefined tm fc get dc -- fixme: undefined
249249 action ii0
250250
251251 fdCacheDurationInSeconds = settingsFdCacheDuration set * 1000000
252+ fdFileInfoDurationInSeconds = settingsFileInfoCacheDuration set * 1000000
252253 withTimeoutManager f = case settingsManager set of
253254 Just tm -> f tm
254255 Nothing -> bracket
warp/Network/Wai/Handler/Warp/Settings.hs+2
@@ -48,6 +48,7 @@ data Settings = Settings
4848 , settingsTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
4949 , settingsManager :: Maybe Manager -- ^ Use an existing timeout manager instead of spawning a new one. If used, 'settingsTimeout' is ignored. Default is 'Nothing'
5050 , settingsFdCacheDuration :: Int -- ^ Cache duration time of file descriptors in seconds. 0 means that the cache mechanism is not used. Default value: 0
51+ , settingsFileInfoCacheDuration :: Int -- ^ Cache duration time of file information in seconds. 0 means that the cache mechanism is not used. Default value: 0
5152 , settingsBeforeMainLoop :: IO ()
5253 -- ^ Code to run after the listening socket is ready but before entering
5354 -- the main event loop. Useful for signaling to tests that they can start
@@ -119,6 +120,7 @@ defaultSettings = Settings
119120 , settingsTimeout = 30
120121 , settingsManager = Nothing
121122 , settingsFdCacheDuration = 0
123+ , settingsFileInfoCacheDuration = 0
122124 , settingsBeforeMainLoop = return ()
123125 , settingsFork = void . forkIOWithUnmask
124126 , settingsNoParsePath = False