]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix plain formatter flush
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 26 Apr 2013 04:30:30 +0000 (21:30 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 26 Apr 2013 19:10:14 +0000 (12:10 -0700)
The plain formatter flush needs to append eol if needed, and
not to clear the sections stack.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_formats.cc
src/rgw/rgw_formats.h

index 61d4d04c7a4f5102e0b558c3aa32b73b7a2a7ddb..66704c4f5bb6fd9be7f57b79996959854bbbfa55 100644 (file)
@@ -36,18 +36,25 @@ void RGWFormatter_Plain::flush(ostream& os)
   if (!buf)
     return;
 
-  os << buf;
-  os.flush();
-  reset();
+  if (len) {
+    os << buf << "\n";
+    os.flush();
+  }
+
+  reset_buf();
 }
 
-void RGWFormatter_Plain::reset()
+void RGWFormatter_Plain::reset_buf()
 {
   free(buf);
   buf = NULL;
   len = 0;
   max_len = 0;
+}
 
+void RGWFormatter_Plain::reset()
+{
+  reset_buf();
   stack.clear();
   min_stack_level = 0;
 }
index 29767851d5f2785ced5b5dbcc77340ff1bb9ced7..0ae917fe7d1a55e0350c3ce45c06bf09170dd079 100644 (file)
@@ -17,6 +17,7 @@ struct plain_stack_entry {
  * There is a much better way to do this.
  */
 class RGWFormatter_Plain : public Formatter {
+  void reset_buf();
 public:
   RGWFormatter_Plain();
   virtual ~RGWFormatter_Plain();