]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: clean up send_reply interface
authorSage Weil <sage@newdream.net>
Mon, 31 Aug 2009 20:05:47 +0000 (13:05 -0700)
committerSage Weil <sage@newdream.net>
Mon, 31 Aug 2009 20:05:47 +0000 (13:05 -0700)
src/mon/ClientMonitor.cc
src/mon/Monitor.cc
src/mon/Monitor.h

index c31468ddb8287b7501baf3e6ee8a629bdc11d12a..cffcaa6611955be4ae0c5802d72228b0f5461d65 100644 (file)
@@ -23,7 +23,6 @@
 #include "messages/MClientMount.h"
 #include "messages/MClientMountAck.h"
 #include "messages/MMonCommand.h"
-#include "messages/MRoute.h"
 
 #include "common/Timer.h"
 
@@ -240,12 +239,7 @@ void ClientMonitor::_mounted(__s64 client, MClientMount *m)
   ack->addr = to.addr;
   mon->monmap->encode(ack->monmap_bl);
 
-  if (m->get_source().is_mon()) {
-    // route reply
-    mon->messenger->send_message(new MRoute(ack, to), m->get_source_inst());
-  } else {
-    mon->messenger->send_message(ack, to);
-  }
+  mon->send_reply(m, ack, to);
 
   // also send latest mds and osd maps
   //mon->mdsmon()->send_latest(to);
index 5013408735d29af4dc01bbe9166e336efc1b22d1..59b76809dd552dbe9d2c5095496c6c62f6a89139 100644 (file)
@@ -310,13 +310,19 @@ void Monitor::reply_command(MMonCommand *m, int rc, const string &rs, bufferlist
 {
   MMonCommandAck *reply = new MMonCommandAck(m->cmd, rc, rs, version);
   reply->set_data(rdata);
-  if (m->get_source().is_mon())
-    messenger->send_message(new MRoute(m, m->get_orig_source_inst()), m->get_source_inst());
-  else 
-    messenger->send_message(reply, m->get_orig_source_inst());
+  send_reply(m, reply);
   delete m;
 }
 
+void Monitor::send_reply(Message *req, Message *reply, entity_inst_t to)
+{
+  if (req->get_source().is_mon()) {
+    messenger->send_message(new MRoute(reply, to), req->get_source_inst());
+  } else {
+    messenger->send_message(reply, to);
+  }
+}
+
 void Monitor::handle_observe(MMonObserve *m)
 {
   dout(10) << "handle_observe " << *m << " from " << m->get_source_inst() << dendl;
index e3b134f18d3c97ef6d7de83f135290f18f6e3a4a..192f9c593fa7aa5a973a1efc208c812f4ac0e6e6 100644 (file)
@@ -139,6 +139,11 @@ public:
   void reply_command(MMonCommand *m, int rc, const string &rs, version_t version);
   void reply_command(MMonCommand *m, int rc, const string &rs, bufferlist& rdata, version_t version);
 
+  void send_reply(Message *req, Message *reply, entity_inst_t to);
+  void send_reply(Message *req, Message *reply) {
+    send_reply(req, reply, req->get_orig_source_inst());
+  }
+
   void inject_args(const entity_inst_t& inst, string& args, version_t version) {
     vector<string> a(1);
     a[0] = args;