]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msgr: make Message::get_orig_* differ only when explicitly directed to
authorSage Weil <sage@newdream.net>
Thu, 25 Mar 2010 20:46:16 +0000 (13:46 -0700)
committerSage Weil <sage@newdream.net>
Tue, 30 Mar 2010 18:40:38 +0000 (11:40 -0700)
This paves the way for removal of the orig_src field from the message
header.

src/messages/MForward.h
src/msg/Message.h

index 633fd948f336c083c64aaed0ed3a53743c91909c..7a7bc2a7f1114d5b95e8e615e423b753fd2d9e9a 100644 (file)
@@ -55,6 +55,7 @@ struct MForward : public Message {
     ::decode(client, p);
     ::decode(client_caps, p);
     msg = (PaxosServiceMessage *)decode_message(p);
+    msg->set_orig_source_inst(client);
   }
 
   const char *get_type_name() { return "forward"; }
index a9a8f2e5eaa6339ccec61ccd7125fcebf5486d4e..a93da15be8411ed4dd2ea9bc7488a778c86cb614 100644 (file)
@@ -220,15 +220,18 @@ protected:
   Connection *connection;
 
   friend class Messenger;
+
+  bool _forwarded;
+  entity_inst_t _orig_source_inst;
   
 public:
   atomic_t nref;
 
-  Message() : connection(NULL), nref(0) {
+  Message() : connection(NULL), _forwarded(false), nref(0) {
     memset(&header, 0, sizeof(header));
     memset(&footer, 0, sizeof(footer));
   };
-  Message(int t) : connection(NULL), nref(0) {
+  Message(int t) : connection(NULL), _forwarded(false), nref(0) {
     memset(&header, 0, sizeof(header));
     header.type = t;
     header.version = 1;
@@ -313,10 +316,21 @@ public:
   entity_addr_t get_source_addr() { return entity_addr_t(header.src.addr); }
   void set_source_inst(entity_inst_t& inst) { header.src = inst; }
 
-  entity_inst_t get_orig_source_inst() { return entity_inst_t(header.orig_src); }
-  entity_name_t get_orig_source() { return entity_name_t(header.orig_src.name); }
-  entity_addr_t get_orig_source_addr() { return entity_addr_t(header.orig_src.addr); }
-  void set_orig_source_inst(entity_inst_t &i) { header.orig_src = i; }
+  entity_inst_t get_orig_source_inst() {
+    if (_forwarded)
+      return _orig_source_inst;
+    return get_source_inst();
+  }
+  entity_name_t get_orig_source() {
+    return get_orig_source_inst().name;
+  }
+  entity_addr_t get_orig_source_addr() {
+    return get_orig_source_inst().addr;
+  }
+  void set_orig_source_inst(entity_inst_t& i) {
+    _forwarded = true;
+    _orig_source_inst = i;
+  }
 
   // virtual bits
   virtual void decode_payload() = 0;