Skip to content

hPutBufNonBlocking can block

This simply escalates an existing TODO in the code base to a ticket.

The function System.IO.hPutBufNonBlocking [1] calls hPutBuf' with can_block = False, which is commented as Bool -- allow blocking? (relevant lines)

However, hPutBuf' calls bufWrite, inside which there's the comment (relevant line):

  if (...)
        -- There's enough room in the buffer:
        -- just copy the data in and update bufR.
        then do ...

        -- else, we have to flush
        else do ...
                old_buf' <- Buffered.flushWriteBuffer haDevice old_buf
                        -- TODO: we should do a non-blocking flush here

so it turns out that if there's not enough room in the Handle buffer, then hPutBufNonBlocking will block.

Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC nh2, simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information