@@ -29,6 +29,7 @@ import Network.Wai.Handler.Warp.Buffer
29import Network.Wai.Handler.Warp.Counter
29import Network.Wai.Handler.Warp.Counter
30import qualified Network.Wai.Handler.Warp.Date as D
30import qualified Network.Wai.Handler.Warp.Date as D
31import qualified Network.Wai.Handler.Warp.FdCache as F
31import qualified Network.Wai.Handler.Warp.FdCache as F
32+import qualified Network.Wai.Handler.Warp.FileInfoCache as I
32import Network.Wai.Handler.Warp.HTTP2 (http2, isHTTP2)
33import Network.Wai.Handler.Warp.HTTP2 (http2, isHTTP2)
33import Network.Wai.Handler.Warp.Header
34import Network.Wai.Handler.Warp.Header
34import Network.Wai.Handler.Warp.ReadInt
35import Network.Wai.Handler.Warp.ReadInt
@@ -237,13 +238,18 @@ runServeSettingsConnectionMakerSecure :: Settings
237runServeSettingsConnectionMakerSecure set getConnMaker serveConn = do
238runServeSettingsConnectionMakerSecure set getConnMaker serveConn = do
238 settingsBeforeMainLoop set
239 settingsBeforeMainLoop set
239 counter <- newCounter
240 counter <- newCounter
241− D.withDateCache $ \dc ->
242− F.withFdCache fdCacheDurationInSeconds $ \fc ->
243− withTimeoutManager $ \tm ->
244− acceptConnection set getConnMaker serveConn dc fc tm counter
241+ withII $ acceptConnection set getConnMaker serveConn counter
244+ D.withDateCache $ \dc ->
245+ F.withFdCache fdCacheDurationInSeconds $ \fc ->
246+ I.withFileInfoCache fdFileInfoDurationInSeconds $ \get ->
247+ withTimeoutManager $ \tm -> do
248+ let ii0 = InternalInfo undefined tm fc get dc -- fixme: undefined
246 fdCacheDurationInSeconds = settingsFdCacheDuration set * 1000000
251 fdCacheDurationInSeconds = settingsFdCacheDuration set * 1000000
252+ fdFileInfoDurationInSeconds = settingsFileInfoCacheDuration set * 1000000
247 withTimeoutManager f = case settingsManager set of
253 withTimeoutManager f = case settingsManager set of
248 Just tm -> f tm
254 Just tm -> f tm
249 Nothing -> bracket
255 Nothing -> bracket
@@ -267,12 +273,10 @@ runServeSettingsConnectionMakerSecure set getConnMaker serveConn = do
267acceptConnection :: Settings
273acceptConnection :: Settings
268 -> IO (IO (Connection, Transport), SockAddr)
274 -> IO (IO (Connection, Transport), SockAddr)
269 -> ServeConnection
275 -> ServeConnection
271− -> Maybe F.MutableFdCache
273 -> Counter
276 -> Counter
275−acceptConnection set getConnMaker serveConn dc fc tm counter = do
279+acceptConnection set getConnMaker serveConn counter ii0 = do
276 -- First mask all exceptions in acceptLoop. This is necessary to
280 -- First mask all exceptions in acceptLoop. This is necessary to
277 -- ensure that no async exception is throw between the call to
281 -- ensure that no async exception is throw between the call to
278 -- acceptNewConnection and the registering of connClose.
282 -- acceptNewConnection and the registering of connClose.
@@ -294,7 +298,7 @@ acceptConnection set getConnMaker serveConn dc fc tm counter = do
294 case mx of
298 case mx of
295 Nothing -> return ()
299 Nothing -> return ()
296 Just (mkConn, addr) -> do
300 Just (mkConn, addr) -> do
297− fork set mkConn addr serveConn dc fc tm counter
301+ fork set mkConn addr serveConn counter ii0
298 acceptLoop
302 acceptLoop
300 acceptNewConnection = do
304 acceptNewConnection = do
@@ -319,12 +323,10 @@ fork :: Settings
319 -> IO (Connection, Transport)
323 -> IO (Connection, Transport)
320 -> SockAddr
324 -> SockAddr
321 -> ServeConnection
325 -> ServeConnection
323− -> Maybe F.MutableFdCache
325 -> Counter
326 -> Counter
327−fork set mkConn addr serveConn dc fc tm counter = settingsFork set $ \ unmask ->
329+fork set mkConn addr serveConn counter ii0 = settingsFork set $ \ unmask ->
328 -- Run the connection maker to get a new connection, and ensure
330 -- Run the connection maker to get a new connection, and ensure
329 -- that the connection is closed. If the mkConn call throws an
331 -- that the connection is closed. If the mkConn call throws an
330 -- exception, we will leak the connection. If the mkConn call is
332 -- exception, we will leak the connection. If the mkConn call is
@@ -339,9 +341,9 @@ fork set mkConn addr serveConn dc fc tm counter = settingsFork set $ \ unmask ->
340 -- We need to register a timeout handler for this thread, and
342 -- We need to register a timeout handler for this thread, and
341 -- cancel that handler as soon as we exit.
343 -- cancel that handler as soon as we exit.
342− bracket (T.registerKillThread tm) T.cancel $ \th ->
344+ bracket (T.registerKillThread (timeoutManager ii0)) T.cancel $ \th ->
344− let ii = InternalInfo th tm fc dc
346+ let ii = ii0 { threadHandle = th }
345 -- We now have fully registered a connection close handler
347 -- We now have fully registered a connection close handler
346 -- in the case of all exceptions, so it is safe to one
348 -- in the case of all exceptions, so it is safe to one
347 -- again allow async exceptions.
349 -- again allow async exceptions.