summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-04-25 21:30:30 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-04-25 21:30:30 -0700
commitdf63677fb16d2b8d5650934ba730446b612c278b (patch)
treeef3f6e010021857af7a9d2919e259136a63c9a0c
parent790e7b1dbd28ea7b3dca551ac9d8f475b361f938 (diff)
downloadceph-df63677fb16d2b8d5650934ba730446b612c278b.tar.gz
rgw: fix plain formatter flush
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>
-rw-r--r--src/rgw/rgw_formats.cc15
-rw-r--r--src/rgw/rgw_formats.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/src/rgw/rgw_formats.cc b/src/rgw/rgw_formats.cc
index 61d4d04c7a4..66704c4f5bb 100644
--- a/src/rgw/rgw_formats.cc
+++ b/src/rgw/rgw_formats.cc
@@ -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;
}
diff --git a/src/rgw/rgw_formats.h b/src/rgw/rgw_formats.h
index 29767851d5f..0ae917fe7d1 100644
--- a/src/rgw/rgw_formats.h
+++ b/src/rgw/rgw_formats.h
@@ -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();