@@ -44,6 +44,7 @@ import Network.Socket (withSocketsDo)
4444#endif
4545
4646#if SENDFILEFD
47+import Control.Applicative
4748import qualified Network.Wai.Handler.Warp.FdCache as F
4849#endif
4950
@@ -71,9 +72,11 @@ socketConnection s = Connection
7172
7273sendFile :: Socket -> FilePath -> Integer -> Integer -> IO () -> [ByteString] -> Cleaner -> IO ()
7374#if SENDFILEFD
74−sendFile s path off len act hdr cleaner = do
75− (fd, fresher) <- F.getFd (fdCacher cleaner) path
76− sendfileFdWithHeader s fd (PartOfFile off len) (act>>fresher) hdr
75+sendFile s path off len act hdr cleaner = case fdCacher cleaner of
76+ Nothing -> sendfileWithHeader s path (PartOfFile off len) act hdr
77+ Just fdc -> do
78+ (fd, fresher) <- F.getFd fdc path
79+ sendfileFdWithHeader s fd (PartOfFile off len) (act>>fresher) hdr
7780#else
7881sendFile s path off len act hdr _ =
7982 sendfileWithHeader s path (PartOfFile off len) act hdr
@@ -129,7 +132,10 @@ runSettingsConnection set getConn app = do
129132 tm <- maybe (T.initialize $ settingsTimeout set * 1000000) return
130133 $ settingsManager set
131134#if SENDFILEFD
132− fc <- F.initialize (settingsFdCacheDuration set * 1000000)
135+ let duration = settingsFdCacheDuration set
136+ fc <- case duration of
137+ 0 -> return Nothing
138+ _ -> Just <$> F.initialize (duration * 1000000)
133139#endif
134140 mask $ \restore -> forever $ do
135141 allowInterrupt