Skip to content

Commit

Permalink
hlint.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jun 22, 2011
1 parent 867b243 commit 601e888
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions Network/Sendfile/BSD.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sendfile sock path range hook = bracket
sendfile'
where
dst = Fd $ fdSocket sock
sendfile' fd = alloca $ \lenp -> do
sendfile' fd = alloca $ \lenp ->
case range of
EntireFile -> sendEntire dst fd 0 lenp hook
PartOfFile off len -> do
Expand All @@ -37,31 +37,31 @@ sendfile sock path range hook = bracket

sendEntire :: Fd -> Fd -> COff -> Ptr COff -> IO () -> IO ()
sendEntire dst src off lenp hook = do
do rc <- c_sendfile src dst off 0 lenp
when (rc /= 0) $ do
errno <- getErrno
if errno == eAGAIN || errno == eINTR
then do
sent <- peek lenp
hook
threadWaitWrite dst
sendEntire dst src (off + sent) lenp hook
else throwErrno "Network.SendFile.BSD.sendEntire"
rc <- c_sendfile src dst off 0 lenp
when (rc /= 0) $ do
errno <- getErrno
if errno `elem` [eAGAIN, eINTR]
then do
sent <- peek lenp
hook
threadWaitWrite dst
sendEntire dst src (off + sent) lenp hook
else throwErrno "Network.SendFile.BSD.sendEntire"

sendPart :: Fd -> Fd -> COff -> CSize -> Ptr COff -> IO () -> IO ()
sendPart dst src off len lenp hook = do
do rc <- c_sendfile src dst off len lenp
when (rc /= 0) $ do
errno <- getErrno
if errno == eAGAIN || errno == eINTR
then do
sent <- peek lenp
let off' = off + sent
len' = len - fromIntegral sent
hook
threadWaitWrite dst
sendPart dst src off' len' lenp hook
else throwErrno "Network.SendFile.BSD.sendPart"
rc <- c_sendfile src dst off len lenp
when (rc /= 0) $ do
errno <- getErrno
if errno `elem` [eAGAIN, eINTR]
then do
sent <- peek lenp
let off' = off + sent
len' = len - fromIntegral sent
hook
threadWaitWrite dst
sendPart dst src off' len' lenp hook
else throwErrno "Network.SendFile.BSD.sendPart"

c_sendfile :: Fd -> Fd -> COff -> CSize -> Ptr COff -> IO CInt
c_sendfile fd s offset len lenp = c_sendfile' fd s offset len nullPtr lenp 0
Expand Down
2 changes: 1 addition & 1 deletion Network/Sendfile/Fallback.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sendIter s hook = do
Nothing -> return ()
Just bs -> do
liftIO $ sendLoop s bs (BS.length bs)
liftIO $ hook -- FIXME: Is this a right place to call the hook?
liftIO hook -- FIXME: Is this a right place to call the hook?
sendIter s hook

sendLoop :: Socket -> ByteString -> Int -> IO ()
Expand Down

0 comments on commit 601e888

Please sign in to comment.