Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 262 by gno...@gmail.com: FileOutputStream::Flush wrongfully flushes entire buffer (not just used bytes)
http://code.google.com/p/protobuf/issues/detail?id=262

What steps will reproduce the problem?
1. Write a small amount of data to a file using a CodedOutputStream wrapping a FileOutputStream
2. Flush the FileOutputStream
3. Close the file

What is the expected output? What do you see instead?
Instead of the file size being the number of bytes written, all the buffer is written (current default in 2.4.0: 8 KiB)

What version of the product are you using? On what operating system?
2.4.0a, Linux 2.6.35-25-generic #44-Ubuntu SMP x86_64

Please provide any additional information below.
The program attached demonstrates the problem: It does the mentioned above, closes the file descriptor and checks the size, which turns out to be 8 KiB instead of just 4 bytes (which is what the program actually writes)

Note that this program isn't correct in the sense that it doesn't delete the CodedOutputStream and the FileOutputStream before it closes the file, but this exactly demonstrates that Flush() is the problem (as opposed to maybe Close() or one of the destructors)

Compile the attached file as follows:
g++ -L"<path to protobuf-2.4.0a lib>" -I"<path to protobuf-2.4.0a include>" ./test_out_stream.cc -lprotobuf -lpthread

Run a.out (NOTE: The program creates a file named "test_file". If you want to run again, delete the created file beforehand)

Attachments:
        test_out_stream.cc  1.2 KB

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to