Skip to content

Commit

Permalink
Defining settingsFdCacheDuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Sep 25, 2012
1 parent fcab266 commit 734bd9d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions warp/Network/Wai/Handler/Warp.hs
Expand Up @@ -31,6 +31,7 @@ module Network.Wai.Handler.Warp (
, settingsTimeout
, settingsIntercept
, settingsManager
, settingsFdCacheDuration
-- ** Data types
, HostPreference (..)
-- * Connection
Expand Down
6 changes: 3 additions & 3 deletions warp/Network/Wai/Handler/Warp/FdCache.hs
Expand Up @@ -76,8 +76,8 @@ look mfc path key = searchWith key check <$> fdCache mfc

----------------------------------------------------------------

initialize :: IO MutableFdCache
initialize = do
initialize :: Int -> IO MutableFdCache
initialize duration = do
mfc <- newMutableFdCache
void . forkIO $ loop mfc
return mfc
Expand All @@ -86,7 +86,7 @@ initialize = do
old <- swapWithNew mfc
new <- pruneWith old prune
update mfc (merge new)
threadDelay 10000000 -- FIXME
threadDelay duration
loop mfc

prune :: t -> Some FdEntry -> IO [(t, Some FdEntry)]
Expand Down
2 changes: 1 addition & 1 deletion warp/Network/Wai/Handler/Warp/Run.hs
Expand Up @@ -126,7 +126,7 @@ runSettingsConnection set getConn app = do
tm <- maybe (T.initialize $ settingsTimeout set * 1000000) return
$ settingsManager set
#if !WINDOWS
fc <- F.initialize
fc <- F.initialize (settingsFdCacheDuration set * 1000000)
#endif
mask $ \restore -> forever $ do
allowInterrupt
Expand Down
2 changes: 2 additions & 0 deletions warp/Network/Wai/Handler/Warp/Settings.hs
Expand Up @@ -25,6 +25,7 @@ data Settings = Settings
, settingsTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
, settingsIntercept :: Request -> Maybe (Source (ResourceT IO) S.ByteString -> Connection -> ResourceT IO ())
, settingsManager :: Maybe Manager -- ^ Use an existing timeout manager instead of spawning a new one. If used, 'settingsTimeout' is ignored. Default is 'Nothing'
, settingsFdCacheDuration :: Int -- ^ Cache duratoin time of file descriptors in seconds. Default value: 10
}

-- | The default settings for the Warp server. See the individual settings for
Expand All @@ -44,6 +45,7 @@ defaultSettings = Settings
, settingsTimeout = 30
, settingsIntercept = const Nothing
, settingsManager = Nothing
, settingsFdCacheDuration = 10
}
where
go :: InvalidRequest -> IO ()
Expand Down

0 comments on commit 734bd9d

Please sign in to comment.