Skip to content

Commit

Permalink
Ensure hGetBufSome does not cause potentially blocking reads (#5843)
Browse files Browse the repository at this point in the history
When there is data in a handle buffer, never fetch more than the
available number of elements, since that can cause a blocking read on
Windows.
  • Loading branch information
pcapriotti committed Mar 27, 2012
1 parent a360b6b commit 370fc0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion GHC/IO/Handle/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,8 @@ hGetBufSome h ptr count
-- that bufReadNBNonEmpty will not
-- issue another read.
else
bufReadNBNonEmpty h_ buf (castPtr ptr) 0 count
let count' = min count (bufferElems buf)
in bufReadNBNonEmpty h_ buf (castPtr ptr) 0 count'

haFD :: Handle__ -> FD
haFD h_@Handle__{..} =
Expand Down

0 comments on commit 370fc0b

Please sign in to comment.