views:

40

answers:

0

Hi all,

I've written a 'sink' using boost::iostreams, so that I can essentially have my own code run when someone tries to write to an iostream object.

Unfortunately there is a buffer somewhere in the system, so that my Sink's write() function only gets called every 4kB or so. This is a problem because the sink I am implementing is a fixed size (e.g. 128 bytes) so once this much data has been written it needs to return an error to the caller (something like 'disk full'.)

Because of the buffer the caller is able to write a few kilobytes of data and no errors are returned, then later when the buffer is flushed the extra data is silently lost, which is causing me problems.

Does anyone know if it's possible to somehow disable this buffer? I've tried many of the suggestions here for generic iostreams (e.g. pubsetbuf) but none of them seem to apply to the Boost implementation.

The problem code is part of a library I am working on, which is available from GitHub if it helps (run 'make check' and you will see one failure because of this problem.)

Any suggestions would be greatly appreciated!