Permalink
Browse files

removing unnecessary hook.

  • Loading branch information...
1 parent cfd7343 commit 7fa8d5768c64048e12d45336ddb0899f6d25f30f @kazu-yamamoto committed Aug 13, 2012
Showing with 8 additions and 15 deletions.
  1. +4 −7 Network/Sendfile/BSD.hsc
  2. +0 −1 Network/Sendfile/Fallback.hs
  3. +4 −7 Network/Sendfile/Linux.hsc
View
@@ -89,7 +89,6 @@ sendfileWithHeader sock path range hook hdr =
-- 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 @@ sendfileWithHeader sock path range hook hdr =
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 @@ sendfileWithHeader sock path range hook hdr =
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 @@ sendloopHeader dst src off len sentp hook hdr hlen = do
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"
@@ -48,5 +48,4 @@ sinkSocket s hook = NeedInput push close
sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO ()
sendfileWithHeader sock path range hook hdr = do
sendMany sock hdr
- hook
sendfile sock path range hook
View
@@ -111,16 +111,13 @@ foreign import ccall unsafe "sendfile"
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 =

0 comments on commit 7fa8d57

Please sign in to comment.