on master help sign in
Merge remote-tracking branch 'origin/master'
commit77aac7e9c7a7a7b8e079522fd834082fb93242c2 authorMichael Snoyman <michael@snoyman.com> dateTue 25 Sep 2012, 13:39 (14 years ago) parente4e61ba51a8994
4 files changed+7−4
warp/Network/Wai/Handler/Warp.hs+1 warp/Network/Wai/Handler/Warp/FdCache.hs+3−3 warp/Network/Wai/Handler/Warp/Run.hs+1−1 warp/Network/Wai/Handler/Warp/Settings.hs+2
warp/Network/Wai/Handler/Warp.hs+1
@@ -31,6 +31,7 @@ module Network.Wai.Handler.Warp (
3131 , settingsTimeout
3232 , settingsIntercept
3333 , settingsManager
34+ , settingsFdCacheDuration
3435 -- ** Data types
3536 , HostPreference (..)
3637 -- * Connection
warp/Network/Wai/Handler/Warp/FdCache.hs+3−3
@@ -76,8 +76,8 @@ look mfc path key = searchWith key check <$> fdCache mfc
7676
7777----------------------------------------------------------------
7878
79−initialize :: IO MutableFdCache
80−initialize = do
79+initialize :: Int -> IO MutableFdCache
80+initialize duration = do
8181 mfc <- newMutableFdCache
8282 void . forkIO $ loop mfc
8383 return mfc
@@ -86,7 +86,7 @@ initialize = do
8686 old <- swapWithNew mfc
8787 new <- pruneWith old prune
8888 update mfc (merge new)
89− threadDelay 10000000 -- FIXME
89+ threadDelay duration
9090 loop mfc
9191
9292prune :: t -> Some FdEntry -> IO [(t, Some FdEntry)]
warp/Network/Wai/Handler/Warp/Run.hs+1−1
@@ -126,7 +126,7 @@ runSettingsConnection set getConn app = do
126126 tm <- maybe (T.initialize $ settingsTimeout set * 1000000) return
127127 $ settingsManager set
128128#if !WINDOWS
129− fc <- F.initialize
129+ fc <- F.initialize (settingsFdCacheDuration set * 1000000)
130130#endif
131131 mask $ \restore -> forever $ do
132132 allowInterrupt
warp/Network/Wai/Handler/Warp/Settings.hs+2
@@ -25,6 +25,7 @@ data Settings = Settings
2525 , settingsTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
2626 , settingsIntercept :: Request -> Maybe (Source (ResourceT IO) S.ByteString -> Connection -> ResourceT IO ())
2727 , settingsManager :: Maybe Manager -- ^ Use an existing timeout manager instead of spawning a new one. If used, 'settingsTimeout' is ignored. Default is 'Nothing'
28+ , settingsFdCacheDuration :: Int -- ^ Cache duratoin time of file descriptors in seconds. Default value: 10
2829 }
2930
3031-- | The default settings for the Warp server. See the individual settings for
@@ -44,6 +45,7 @@ defaultSettings = Settings
4445 , settingsTimeout = 30
4546 , settingsIntercept = const Nothing
4647 , settingsManager = Nothing
48+ , settingsFdCacheDuration = 10
4749 }
4850 where
4951 go :: InvalidRequest -> IO ()