]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MonOpRequest: add 'send_reply()' function
authorJoao Eduardo Luis <joao@redhat.com>
Fri, 27 Feb 2015 15:58:06 +0000 (15:58 +0000)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 16 Jul 2015 17:03:39 +0000 (18:03 +0100)
Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
src/mon/Makefile.am
src/mon/MonOpRequest.cc [new file with mode: 0644]
src/mon/MonOpRequest.h

index ee6542d42d51ef0171de01544d488ad577778563..476acef7797263ba57c3f9202bec27ae564d2bf1 100644 (file)
@@ -18,7 +18,8 @@ libmon_la_SOURCES = \
        mon/Elector.cc \
        mon/HealthMonitor.cc \
        mon/DataHealthService.cc \
-       mon/ConfigKeyService.cc
+       mon/ConfigKeyService.cc \
+       mon/MonOpRequest.cc
 libmon_la_LIBADD = $(LIBAUTH) $(LIBCOMMON) $(LIBOS) $(LIBMON_TYPES)
 noinst_LTLIBRARIES += libmon.la
 
diff --git a/src/mon/MonOpRequest.cc b/src/mon/MonOpRequest.cc
new file mode 100644 (file)
index 0000000..e61a471
--- /dev/null
@@ -0,0 +1,41 @@
+#include <sstream>
+#include "msg/Messenger.h"
+#include "msg/Message.h"
+#include "messages/MRoute.h"
+
+#include "mon/MonOpRequest.h"
+#include "mon/Session.h"
+
+#define dout_subsys ceph_subsys_mon
+#undef dout_prefix
+#define dout_prefix _prefix(_dout, this)
+static ostream& _prefix(std::ostream *_dout, const MonOpRequest *op) {
+  *_dout << "optracker foo ";
+  return *_dout;
+}
+
+void MonOpRequest::send_reply(Message *reply)
+{
+  if (!session) {
+    dout(2) << "send_reply no session, dropping reply " << *reply
+           << " to " << request << " " << *request << dendl;
+    reply->put();
+    return;
+  }
+
+  if (!session->con && !session->proxy_con) {
+    dout(2) << "send_reply no connection, dropping reply " << *reply
+           << " to " << request << " " << *request << dendl;
+    reply->put();
+    return;
+  }
+
+  if (session->proxy_con) {
+    dout(15) << "send_reply routing reply to " << con->get_peer_addr()
+            << " via " << session->proxy_con->get_peer_addr()
+            << " for request " << *request << dendl;
+    session->proxy_con->send_message(new MRoute(session->proxy_tid, reply));
+  } else {
+    session->con->send_message(reply);
+  }
+}
index 810158467bf4cded260556b5e20b15fc1e56ed37..3dece4f43c3378bd3d2c1be3a84555fbdfe25096 100644 (file)
@@ -93,6 +93,8 @@ public:
   }
 
   typedef ceph::shared_ptr<MonOpRequest> Ref;
+
+  void send_reply(Message *reply);
 };
 
 typedef MonOpRequest::Ref MonOpRequestRef;