Browse Source

Explicitly propagate the status of Flush().

Before the change, an implicit Flush() will be triggered in the
destructor of the input stream. However, the return code of Flush() is
not discarded. This change makes sure when Flush() fails, we will
return false.
Jisi Liu 7 years ago
parent
commit
6b01e6440c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/google/protobuf/message.cc

+ 2 - 2
src/google/protobuf/message.cc

@@ -170,12 +170,12 @@ size_t Message::SpaceUsedLong() const {
 
 
 bool Message::SerializeToFileDescriptor(int file_descriptor) const {
 bool Message::SerializeToFileDescriptor(int file_descriptor) const {
   io::FileOutputStream output(file_descriptor);
   io::FileOutputStream output(file_descriptor);
-  return SerializeToZeroCopyStream(&output);
+  return SerializeToZeroCopyStream(&output) && output.Flush();
 }
 }
 
 
 bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
 bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
   io::FileOutputStream output(file_descriptor);
   io::FileOutputStream output(file_descriptor);
-  return SerializePartialToZeroCopyStream(&output);
+  return SerializePartialToZeroCopyStream(&output) && output.Flush();
 }
 }
 
 
 bool Message::SerializeToOstream(std::ostream* output) const {
 bool Message::SerializeToOstream(std::ostream* output) const {