]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: track stamp of last keepalive[2] received
authorSage Weil <sage@redhat.com>
Tue, 6 Oct 2015 19:08:57 +0000 (15:08 -0400)
committerSage Weil <sage@redhat.com>
Mon, 23 Nov 2015 13:38:47 +0000 (08:38 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/Connection.h
src/msg/async/AsyncConnection.cc
src/msg/simple/Pipe.cc

index 1539b39100de4d829beb68c8ede5c595ef95eb5c..d54b7d6e7eff8316efb87c8bd1b08e1ed95fe781 100644 (file)
@@ -44,7 +44,7 @@ struct Connection : public RefCountedObject {
   RefCountedObject *priv;
   int peer_type;
   entity_addr_t peer_addr;
-  utime_t last_keepalive_ack;
+  utime_t last_keepalive, last_keepalive_ack;
 private:
   uint64_t features;
 public:
@@ -178,9 +178,19 @@ public:
     rx_buffers.erase(tid);
   }
 
+  utime_t get_last_keepalive() const {
+    return last_keepalive;
+  }
+  void set_last_keepalive(utime_t t) {
+    last_keepalive = t;
+  }
   utime_t get_last_keepalive_ack() const {
     return last_keepalive_ack;
   }
+  void set_last_keepalive_ack(utime_t t) {
+    last_keepalive_ack = t;
+  }
+
 };
 
 typedef boost::intrusive_ptr<Connection> ConnectionRef;
index 71e4931989408fc6dc418e30f7b4c500c6cf9a58..57dd9d5a3b54a4362a763e5b2026ddaf5d7eba79 100644 (file)
@@ -458,6 +458,7 @@ void AsyncConnection::process()
 
           if (tag == CEPH_MSGR_TAG_KEEPALIVE) {
             ldout(async_msgr->cct, 20) << __func__ << " got KEEPALIVE" << dendl;
+           set_last_keepalive(ceph_clock_now(NULL));
           } else if (tag == CEPH_MSGR_TAG_KEEPALIVE2) {
             state = STATE_OPEN_KEEPALIVE2;
           } else if (tag == CEPH_MSGR_TAG_KEEPALIVE2_ACK) {
@@ -492,8 +493,9 @@ void AsyncConnection::process()
           utime_t kp_t = utime_t(*t);
           write_lock.Lock();
           _send_keepalive_or_ack(true, &kp_t);
-          write_lock.Unlock();
+         write_lock.Unlock();
           ldout(async_msgr->cct, 20) << __func__ << " got KEEPALIVE2 " << kp_t << dendl;
+         set_last_keepalive(ceph_clock_now(NULL));
           state = STATE_OPEN;
           break;
         }
@@ -510,7 +512,7 @@ void AsyncConnection::process()
           }
 
           t = (ceph_timespec*)state_buffer;
-          last_keepalive_ack = utime_t(*t);
+          set_last_keepalive_ack(utime_t(*t));
           ldout(async_msgr->cct, 20) << __func__ << " got KEEPALIVE_ACK" << dendl;
           state = STATE_OPEN;
           break;
index d1483785de7ce3bd5efebcce24fcdc0e36f7cd8b..f14da82e9f006268ef0c6ec39c28feb4b09d45d6 100644 (file)
@@ -1517,6 +1517,7 @@ void Pipe::reader()
     if (tag == CEPH_MSGR_TAG_KEEPALIVE) {
       ldout(msgr->cct,20) << "reader got KEEPALIVE" << dendl;
       pipe_lock.Lock();
+      connection_state->set_last_keepalive(ceph_clock_now(NULL));
       continue;
     }
     if (tag == CEPH_MSGR_TAG_KEEPALIVE2) {
@@ -1533,6 +1534,7 @@ void Pipe::reader()
        keepalive_ack_stamp = utime_t(t);
        ldout(msgr->cct,20) << "reader got KEEPALIVE2 " << keepalive_ack_stamp
                            << dendl;
+       connection_state->set_last_keepalive(ceph_clock_now(NULL));
        cond.Signal();
       }
       continue;
@@ -1546,7 +1548,7 @@ void Pipe::reader()
        ldout(msgr->cct,2) << "reader couldn't read KEEPALIVE2 stamp " << cpp_strerror(errno) << dendl;
        fault(true);
       } else {
-       connection_state->last_keepalive_ack = utime_t(t);
+       connection_state->set_last_keepalive_ack(utime_t(t));
       }
       continue;
     }