]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msgr: Remove _my_name and ms_addr, replace with direct access to my_inst.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 23 Mar 2012 20:28:07 +0000 (13:28 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 3 Apr 2012 20:13:33 +0000 (13:13 -0700)
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/msg/Messenger.h
src/msg/SimpleMessenger.cc
src/msg/SimpleMessenger.h

index 0865f9c0d8627d255507205d2a8ef94aae923baa..276f2c76f692a2fa8470b1b7686a5f5f934aca7d 100644 (file)
@@ -75,7 +75,6 @@ private:
 protected:
   /// the "name" of the local daemon. eg client.99
   entity_inst_t my_inst;
-  entity_name_t& _my_name;
   int default_send_priority;
   /// set to true once the Messenger has started, and set to false on shutdown
   bool started;
@@ -84,11 +83,10 @@ protected:
   CephContext *cct;
   Messenger(CephContext *cct_, entity_name_t w)
     : my_inst(),
-      _my_name(my_inst.name),
       default_send_priority(CEPH_MSG_PRIO_DEFAULT), started(false),
       cct(cct_)
   {
-    _my_name = w;
+    my_inst.name = w;
   }
   virtual ~Messenger() {}
 
@@ -96,7 +94,7 @@ protected:
   }
 
   // accessors
-  const entity_name_t& get_myname() { return _my_name; }
+  const entity_name_t& get_myname() { return my_inst.name; }
   /**
    * Retrieve the Messenger's address.
    *
@@ -114,7 +112,7 @@ protected:
    *
    * @param m The name to set.
    */
-  void set_myname(const entity_name_t m) { _my_name = m; }
+  void set_myname(const entity_name_t m) { my_inst.name = m; }
 
   /**
    * Set the default send priority
index 0cefaa56073644cdb87ca4020432a564a7f62e55..0107efc59c8739a129d1390caf367b956d9aeef8 100644 (file)
@@ -46,7 +46,7 @@
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, msgr)
 static ostream& _prefix(std::ostream *_dout, SimpleMessenger *msgr) {
-  return *_dout << "-- " << msgr->ms_addr << " ";
+  return *_dout << "-- " << msgr->get_myaddr() << " ";
 }
 
 
@@ -145,20 +145,20 @@ int SimpleMessenger::Accepter::bind(entity_addr_t &bind_addr, int avoid_port1, i
     return -errno;
   }
   
-  msgr->ms_addr = bind_addr;
-  if (msgr->ms_addr != entity_addr_t())
+  msgr->my_inst.addr = bind_addr;
+  if (msgr->my_inst.addr != entity_addr_t())
     msgr->need_addr = false;
   else 
     msgr->need_addr = true;
 
-  if (msgr->ms_addr.get_port() == 0) {
-    msgr->ms_addr = listen_addr;
-    msgr->ms_addr.nonce = msgr->nonce;
+  if (msgr->my_inst.addr.get_port() == 0) {
+    msgr->my_inst.addr = listen_addr;
+    msgr->my_inst.addr.nonce = msgr->nonce;
   }
 
   msgr->init_local_pipe();
 
-  ldout(msgr->cct,1) << "accepter.bind ms_addr is " << msgr->ms_addr << " need_addr=" << msgr->need_addr << dendl;
+  ldout(msgr->cct,1) << "accepter.bind my_inst.addr is " << msgr->my_inst.addr << " need_addr=" << msgr->need_addr << dendl;
   msgr->did_bind = true;
   return 0;
 }
@@ -170,7 +170,7 @@ int SimpleMessenger::Accepter::rebind(int avoid_port)
   
   stop();
 
-  entity_addr_t addr = msgr->ms_addr;
+  entity_addr_t addr = msgr->my_inst.addr;
   int old_port = addr.get_port();
   addr.set_port(0);
 
@@ -488,15 +488,15 @@ int SimpleMessenger::lazy_send_message(Message *m, const entity_inst_t& dest)
 }
 
 /**
- * If ms_addr doesn't have an IP set, this function
+ * If my_inst.addr doesn't have an IP set, this function
  * will fill it in from the passed addr. Otherwise it does nothing and returns.
  */
 void SimpleMessenger::set_ip(entity_addr_t &addr)
 {
-  if (ms_addr.is_blank_ip()) {
-    int port = ms_addr.get_port();
-    ms_addr.addr = addr.addr;
-    ms_addr.set_port(port);
+  if (my_inst.addr.is_blank_ip()) {
+    int port = my_inst.addr.get_port();
+    my_inst.addr.addr = addr.addr;
+    my_inst.addr.set_port(port);
   }
 }
 
@@ -533,7 +533,7 @@ int SimpleMessenger::get_proto_version(int peer_type, bool connect)
 #undef dout_prefix
 #define dout_prefix _pipe_prefix(_dout)
 ostream& SimpleMessenger::Pipe::_pipe_prefix(std::ostream *_dout) {
-  return *_dout << "-- " << msgr->ms_addr << " >> " << peer_addr << " pipe(" << this
+  return *_dout << "-- " << msgr->my_inst.addr << " >> " << peer_addr << " pipe(" << this
                << " sd=" << sd
                << " pgs=" << peer_global_seq
                << " cs=" << connect_seq
@@ -620,7 +620,7 @@ int SimpleMessenger::Pipe::accept()
 
   // and my addr
   bufferlist addrs;
-  ::encode(msgr->ms_addr, addrs);
+  ::encode(msgr->my_inst.addr, addrs);
 
   // and peer's socket addr (they might not know their ip)
   entity_addr_t socket_addr;
@@ -824,7 +824,7 @@ int SimpleMessenger::Pipe::accept()
 
       if (connect.connect_seq == existing->connect_seq) {
        // connection race?
-       if (peer_addr < msgr->ms_addr ||
+       if (peer_addr < msgr->my_inst.addr ||
            existing->policy.server) {
          // incoming wins
          ldout(msgr->cct,10) << "accept connection race, existing " << existing << ".cseq " << existing->connect_seq
@@ -844,7 +844,7 @@ int SimpleMessenger::Pipe::accept()
          // our existing outgoing wins
          ldout(msgr->cct,10) << "accept connection race, existing " << existing << ".cseq " << existing->connect_seq
                   << " == " << connect.connect_seq << ", sending WAIT" << dendl;
-         assert(peer_addr > msgr->ms_addr);
+         assert(peer_addr > msgr->my_inst.addr);
          if (!(existing->state == STATE_CONNECTING ||
                existing->state == STATE_OPEN))
            lderr(msgr->cct) << "accept race bad state, would send wait, existing=" << existing->state
@@ -1133,7 +1133,7 @@ int SimpleMessenger::Pipe::connect()
   if (msgr->need_addr)
     msgr->learned_addr(peer_addr_for_me);
 
-  ::encode(msgr->ms_addr, myaddrbl);
+  ::encode(msgr->my_inst.addr, myaddrbl);
 
   memset(&msg, 0, sizeof(msg));
   msgvec[0].iov_base = myaddrbl.c_str();
@@ -1145,7 +1145,7 @@ int SimpleMessenger::Pipe::connect()
     ldout(msgr->cct,2) << "connect couldn't write my addr, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
-  ldout(msgr->cct,10) << "connect sent my addr " << msgr->ms_addr << dendl;
+  ldout(msgr->cct,10) << "connect sent my addr " << msgr->my_inst.addr << dendl;
 
 
   while (1) {
@@ -2407,7 +2407,7 @@ int SimpleMessenger::start()
   started = true;
 
   if (!did_bind)
-    ms_addr.nonce = nonce;
+    my_inst.addr.nonce = nonce;
 
   lock.Unlock();
 
@@ -2426,7 +2426,7 @@ int SimpleMessenger::start()
 SimpleMessenger::Pipe *SimpleMessenger::connect_rank(const entity_addr_t& addr, int type)
 {
   assert(lock.is_locked());
-  assert(addr != ms_addr);
+  assert(addr != my_inst.addr);
   
   ldout(cct,10) << "connect_rank to " << addr << ", creating pipe and registering" << dendl;
   
@@ -2488,7 +2488,7 @@ Connection *SimpleMessenger::get_connection(const entity_inst_t& dest)
 {
   Mutex::Locker l(lock);
   Pipe *pipe = NULL;
-  if (ms_addr == dest.addr) {
+  if (my_inst.addr == dest.addr) {
     // local
     pipe = dispatch_queue.local_pipe;
   } else {
@@ -2529,7 +2529,7 @@ void SimpleMessenger::submit_message(Message *m, const entity_addr_t& dest_addr,
   lock.Lock();
   {
     // local?
-    if (ms_addr == dest_addr) {
+    if (my_inst.addr == dest_addr) {
       if (!destination_stopped) {
         // local
         ldout(cct,20) << "submit_message " << *m << " local" << dendl;
@@ -2587,7 +2587,7 @@ int SimpleMessenger::send_keepalive(const entity_inst_t& dest)
   lock.Lock();
   {
     // local?
-    if (ms_addr != dest_addr) {
+    if (my_inst.addr != dest_addr) {
       // remote.
       Pipe *pipe = 0;
       if (rank_pipe.count( dest_proc_addr )) {
@@ -2796,13 +2796,13 @@ void SimpleMessenger::mark_disposable(Connection *con)
 void SimpleMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
 {
   // be careful here: multiple threads may block here, and readers of
-  // ms_addr do NOT hold any lock.
+  // my_inst.addr do NOT hold any lock.
   lock.Lock();
   if (need_addr) {
     entity_addr_t t = peer_addr_for_me;
-    t.set_port(ms_addr.get_port());
-    ms_addr.addr = t.addr;
-    ldout(cct,1) << "learned my addr " << ms_addr << dendl;
+    t.set_port(my_inst.addr.get_port());
+    my_inst.addr.addr = t.addr;
+    ldout(cct,1) << "learned my addr " << my_inst.addr << dendl;
     need_addr = false;
     init_local_pipe();
   }
@@ -2811,6 +2811,6 @@ void SimpleMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
 
 void SimpleMessenger::init_local_pipe()
 {
-  dispatch_queue.local_pipe->connection_state->peer_addr = msgr->ms_addr;
+  dispatch_queue.local_pipe->connection_state->peer_addr = msgr->my_inst.addr;
   dispatch_queue.local_pipe->connection_state->peer_type = msgr->my_type;
 }
index 0ab9062e2d5aed788caaf9d9e7b66f2c214bd878..51b6f65538e1041ea4055926fdc9a0a85b1292ed 100644 (file)
@@ -468,7 +468,6 @@ private:
 
   // where i listen
   bool need_addr;
-  entity_addr_t& ms_addr;
   uint64_t nonce;
   
   // local
@@ -570,7 +569,6 @@ public:
     accepter(this),
     lock("SimpleMessenger::lock"), did_bind(false),
     dispatch_throttler(cct->_conf->ms_dispatch_throttle_bytes), need_addr(true),
-    ms_addr(my_inst.addr),
     nonce(_nonce), destination_stopped(false), my_type(name.type()),
     global_seq_lock("SimpleMessenger::global_seq_lock"), global_seq(0),
     reaper_thread(this), reaper_started(false), reaper_stop(false),