simple-sendfile 0.2.5 → 0.2.6
raw patch · 5 files changed
+13/−21 lines, 5 filesdep +hspec-expectationsdep −hspec-discoverdep −hspec-shouldbedep ~hspec
Dependencies added: hspec-expectations
Dependencies removed: hspec-discover, hspec-shouldbe
Dependency ranges changed: hspec
Files
- Network/Sendfile/BSD.hsc +4/−7
- Network/Sendfile/Fallback.hs +0/−1
- Network/Sendfile/Linux.hsc +4/−7
- simple-sendfile.cabal +3/−4
- test/SendfileSpec.hs +2/−2
Network/Sendfile/BSD.hsc view
@@ -89,7 +89,6 @@ -- threadWaitWrite does not come back on FreeBSD, sigh. -- We use writev() for the header and sendfile() for the file. sendMany sock hdr- hook sendfile sock path range hook else do -- On MacOS, the header and the body are sent separately.@@ -99,11 +98,10 @@ EntireFile -> (0,entire) PartOfFile off' len' -> (fromInteger off' ,fromInteger len' + hlen)- mrc <- sendloopHeader dst fd off len sentp hook hdr hlen+ mrc <- sendloopHeader dst fd off len sentp hdr hlen case mrc of Nothing -> return () Just (newoff,newlen) -> do- hook threadWaitWrite dst sendloop dst fd newoff newlen sentp hook where@@ -112,8 +110,8 @@ dst = Fd $ fdSocket sock hlen = fromIntegral . sum . map BS.length $ hdr -sendloopHeader :: Fd -> Fd -> COff -> COff -> Ptr COff -> IO () -> [ByteString] -> COff -> IO (Maybe (COff, COff))-sendloopHeader dst src off len sentp hook hdr hlen = do+sendloopHeader :: Fd -> Fd -> COff -> COff -> Ptr COff -> [ByteString] -> COff -> IO (Maybe (COff, COff))+sendloopHeader dst src off len sentp hdr hlen = do rc <- withSfHdtr hdr $ sendFile src dst off len sentp if rc == 0 then return Nothing@@ -128,12 +126,11 @@ else return $ Just (newoff, len - sent) else do- hook threadWaitWrite dst let newlen = if len == entire then entire else len - sent newhdr = remainingChunks (fromIntegral sent) hdr newhlen = hlen - sent- sendloopHeader dst src off newlen sentp hook newhdr newhlen+ sendloopHeader dst src off newlen sentp newhdr newhlen else throwErrno "Network.SendFile.MacOS.sendloopHeader"
Network/Sendfile/Fallback.hs view
@@ -48,5 +48,4 @@ sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO () sendfileWithHeader sock path range hook hdr = do sendMany sock hdr- hook sendfile sock path range hook
Network/Sendfile/Linux.hsc view
@@ -111,16 +111,13 @@ sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO () sendfileWithHeader sock path range hook hdr = do -- Copying is much faster than syscall.- sendAllMsgMore sock hook $ B.concat hdr- hook+ sendAllMsgMore sock $ B.concat hdr sendfile sock path range hook -sendAllMsgMore :: Socket -> IO () -> ByteString -> IO ()-sendAllMsgMore sock hook bs = do+sendAllMsgMore :: Socket -> ByteString -> IO ()+sendAllMsgMore sock bs = do sent <- sendMsgMore sock bs- when (sent < B.length bs) $ do- hook- sendAllMsgMore sock hook (B.drop sent bs)+ when (sent < B.length bs) $ sendAllMsgMore sock (B.drop sent bs) sendMsgMore :: Socket -> ByteString -> IO Int sendMsgMore (MkSocket s _ _ _ _) xs =
simple-sendfile.cabal view
@@ -1,5 +1,5 @@ Name: simple-sendfile-Version: 0.2.5+Version: 0.2.6 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3@@ -56,9 +56,8 @@ , bytestring , conduit , directory- , hspec- , hspec-discover- , hspec-shouldbe+ , hspec >= 1.3+ , hspec-expectations , network , network-conduit , process
test/SendfileSpec.hs view
@@ -16,10 +16,10 @@ import System.Directory import System.Exit import System.IO-import System.Process-import Test.Hspec.ShouldBe import System.Posix.Files+import System.Process import System.Timeout+import Test.Hspec ----------------------------------------------------------------