Opened 12 years ago

Last modified 11 years ago

#5174 new Patches

Patch to make code_converter flushable

Reported by: eddie@… Owned by: Jonathan Turkanis
Milestone: To Be Determined Component: iostreams
Version: Boost 1.45.0 Severity: Problem
Keywords: code_converter flush sync buffer iostreams Cc: eddie@…

Description

I've attached a little patch that makes iostreams::code_converter flushable. It seems like it really should be. Is there any chance someone could look at this? I've included some test code as well that outputs the following.

The reason I need this functionality is because I am converting the fastcgi++ library over to use boost iostreams for filtering capabilities. Unfortunately if the code_converter can not flush it is useless.

OUTPUT BEFORE PATCH

main(): Sending 24 characters of data to output stream SinkDev::write(): Recieved 16 characters. main(): Calling a sync on the output stream main(): Sending 21 characters of data to output stream SinkDev::write(): Recieved 16 characters.

main(): Asking for 24 characters of data from input stream SourceDev::read(): Sending 16 characters. SourceDev::read(): Sending 16 characters. main(): Calling a sync on the input stream main(): Asking for 9 characters of data from input stream SourceDev::read(): Sending 16 characters.

main(): At end of test case SinkDev::write(): Recieved 13 characters.

OUTPUT AFTER PATCH

main(): Sending 24 characters of data to output stream SinkDev::write(): Recieved 16 characters. main(): Calling a sync on the output stream SinkDev::write(): Recieved 8 characters. main(): Sending 21 characters of data to output stream SinkDev::write(): Recieved 16 characters.

main(): Asking for 24 characters of data from input stream SourceDev::read(): Sending 16 characters. SourceDev::read(): Sending 16 characters. main(): Calling a sync on the input stream main(): Asking for 9 characters of data from input stream SourceDev::read(): Sending 16 characters.

main(): At end of test case SinkDev::write(): Recieved 5 characters. SinkDev::write(): Recieved 0 characters. SinkDev::write(): Recieved 0 characters. SinkDev::write(): Recieved 0 characters.

END

Notice that input functionality doesn't change but the output functionality does. The one cause for concern to me is that for some reason upon deconstruction the new flush() function is called a bunch of extras times. I'm not entirely sure why this is happening. --

Eddie Carle

Attachments (3)

code_converter-flushable.diff (1.6 KB ) - added by eddie@… 12 years ago.
Patch to boost trunk
codeConverterTestcase.cpp (1.9 KB ) - added by eddie@… 12 years ago.
Test case for patch
code_converter_patch (863 bytes ) - added by beder@… 11 years ago.
Patch to the trunk for flushing the code_converter

Download all attachments as: .zip

Change History (6)

by eddie@…, 12 years ago

Patch to boost trunk

by eddie@…, 12 years ago

Attachment: codeConverterTestcase.cpp added

Test case for patch

by beder@…, 11 years ago

Attachment: code_converter_patch added

Patch to the trunk for flushing the code_converter

comment:1 by anonymous, 11 years ago

Is there an update on this ticket? I came across this same issue, and I patched it similarly (although a little easier, I think) - see code_converter_patch. It would be very useful to get this into the trunk; and if there's some technical reason why not, what is it?

The reason I need it is that I'm using code_converter in a stream many times per second, and it costs too much to construct and destroy the stream to force a flush.

Thanks, Jesse Beder

comment:2 by beder@…, 11 years ago

Sorry, I meant to put my email above - I didn't intend to be anonymous.

comment:3 by Eddie Carle <eddie@…>, 11 years ago

Yeah, I was in contact with the maintainer a while back and he said he would pursue it but didn't. I eventually gave up and included a replacement code_converter.hpp in the fastcgi++ library. I am intrigued at the simplicity of your patch though. I wonder why I didn't do it like that.

Note: See TracTickets for help on using tickets.