From 4ca1407fd9e69d9c43da70e8ebfc015c73f9f63f Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 16 Oct 2013 01:31:20 +0100 Subject: [PATCH] mon: Monitor: do not flush formatter at end of _mon_status() 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 --- src/mon/Monitor.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index d8c90bc3d7653..8ecd45b05e9d6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -241,9 +241,11 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format, boost::scoped_ptr 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; -- 2.39.5