Skip to content

Commit

Permalink
fixing over-protection for sendAll.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jan 20, 2022
1 parent e11132d commit e01007e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Network/Socket/ByteString/IO.hsc
Expand Up @@ -95,9 +95,10 @@ sendAll :: Socket -- ^ Connected socket
-> IO ()
sendAll _ "" = return ()
sendAll s bs = do
-- "send" throws an exception.
sent <- send s bs
waitWhen0 sent s
when (sent >= 0) $ sendAll s $ B.drop sent bs
when (sent /= B.length bs) $ sendAll s $ B.drop sent bs

-- | Send data to the socket. The recipient can be specified
-- explicitly, so the socket need not be in a connected state.
Expand Down
3 changes: 2 additions & 1 deletion Network/Socket/ByteString/Lazy/Posix.hs
Expand Up @@ -52,6 +52,7 @@ sendAll
-> IO ()
sendAll _ "" = return ()
sendAll s bs = do
-- "send" throws an exception.
sent <- send s bs
waitWhen0 (fromIntegral sent) s
when (sent >= 0) $ sendAll s $ L.drop sent bs
when (sent /= L.length bs) $ sendAll s $ L.drop sent bs
3 changes: 2 additions & 1 deletion Network/Socket/ByteString/Lazy/Windows.hs
Expand Up @@ -30,6 +30,7 @@ sendAll
-> IO ()
sendAll _ "" = return ()
sendAll s bs = do
-- "send" throws an exception.
sent <- send s bs
waitWhen0 (fromIntegral sent) s
when (sent >= 0) $ sendAll s $ L.drop sent bs
when (sent /= L.length bs) $ sendAll s $ L.drop sent bs

0 comments on commit e01007e

Please sign in to comment.