]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: do not flush formatter at end of _mon_status()
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 16 Oct 2013 00:31:20 +0000 (01:31 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 23 Oct 2013 01:52:01 +0000 (02:52 +0100)
Delegate that to the caller so that we can combine the result of
_mon_status() with the result of other functions.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Monitor.cc

index d8c90bc3d7653855c24df7c3ad1c34ee60cfb3c2..8ecd45b05e9d68b820550fec2bddc729f9376485 100644 (file)
@@ -241,9 +241,11 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format,
 
   boost::scoped_ptr<Formatter> f(new_formatter(format));
 
-  if (command == "mon_status")
+  if (command == "mon_status") {
     _mon_status(f.get(), ss);
-  else if (command == "quorum_status")
+    if (f)
+      f->flush(ss);
+  } else if (command == "quorum_status")
     _quorum_status(f.get(), ss);
   else if (command == "sync_force") {
     string validate;
@@ -1673,9 +1675,11 @@ void Monitor::_mon_status(Formatter *f, ostream& ss)
 
   f->close_section(); // mon_status
 
-  f->flush(ss);
-  if (free_formatter)
+  if (free_formatter) {
+    // flush formatter to ss and delete it iff we created the formatter
+    f->flush(ss);
     delete f;
+  }
 }
 
 void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f)
@@ -2176,6 +2180,8 @@ void Monitor::handle_command(MMonCommand *m)
     r = 0;
   } else if (prefix == "mon_status") {
     _mon_status(f.get(), ds);
+    if (f)
+      f->flush(ds);
     rdata.append(ds);
     rs = "";
     r = 0;