on master help sign in
using FdCache for BSD variants.
1c461e4Kazu Yamamoto
warp/Network/Wai/Handler/Warp/FdCache.hs+1−1
@@ -2,7 +2,7 @@
2
2
3-- | File descriptor cache to avoid locks in kernel.
3-- | File descriptor cache to avoid locks in kernel.
4
4
5−#ifndef SENDFILEFD
5+#ifdef WINDOWS
6module Network.Wai.Handler.Warp.FdCache (
6module Network.Wai.Handler.Warp.FdCache (
7 withFdCache
7 withFdCache
8 , MutableFdCache
8 , MutableFdCache
warp/Network/Wai/Handler/Warp/Response.hs+4−4
@@ -244,16 +244,16 @@ sendRsp conn mfdc ver s0 hs0 (RspFile path mPart mRange isHead hook) = do
244 sendRsp conn mfdc ver s hs1 (RspBuilder mempty False)
244 sendRsp conn mfdc ver s hs1 (RspBuilder mempty False)
245 else do
245 else do
246 lheader <- composeHeader ver s hs1
246 lheader <- composeHeader ver s hs1
247−#ifdef SENDFILEFD
247+#ifdef WINDOWS
248+ let fid = FileId path Nothing
249+ hook' = hook
250+#else
248 (mfd, hook') <- case mfdc of
251 (mfd, hook') <- case mfdc of
249 Nothing -> return (Nothing, hook)
252 Nothing -> return (Nothing, hook)
250 Just fdc -> do
253 Just fdc -> do
251 (fd, fresher) <- F.getFd fdc path
254 (fd, fresher) <- F.getFd fdc path
252 return (Just fd, hook >> fresher)
255 return (Just fd, hook >> fresher)
253 let fid = FileId path mfd
256 let fid = FileId path mfd
254−#else
255− let fid = FileId path Nothing
256− hook' = hook
257#endif
257#endif
258 connSendFile conn fid beg len hook' [lheader]
258 connSendFile conn fid beg len hook' [lheader]
259 | otherwise -> do
259 | otherwise -> do
warp/Network/Wai/Handler/Warp/Types.hs+2−2
@@ -16,7 +16,7 @@ import qualified Network.Wai.Handler.Warp.Date as D
16import qualified Network.Wai.Handler.Warp.FdCache as F
16import qualified Network.Wai.Handler.Warp.FdCache as F
17import qualified Network.Wai.Handler.Warp.Timeout as T
17import qualified Network.Wai.Handler.Warp.Timeout as T
18
18
19−#ifdef SENDFILEFD
19+#ifndef WINDOWS
20import System.Posix.Types (Fd)
20import System.Posix.Types (Fd)
21#endif
21#endif
22
22
@@ -67,7 +67,7 @@ instance Exception InvalidRequest
67
67
68----------------------------------------------------------------
68----------------------------------------------------------------
69
69
70−#ifndef SENDFILEFD
70+#ifdef WINDOWS
71type Fd = ()
71type Fd = ()
72#endif
72#endif
73
73
warp/test/FdCacheSpec.hs+1−1
@@ -3,7 +3,7 @@
3module FdCacheSpec where
3module FdCacheSpec where
4
4
5import Test.Hspec
5import Test.Hspec
6−#ifdef SENDFILEFD
6+#ifndef WINDOWS
7import Data.IORef
7import Data.IORef
8import Network.Wai.Handler.Warp.FdCache
8import Network.Wai.Handler.Warp.FdCache
9import System.Posix.IO (fdRead)
9import System.Posix.IO (fdRead)