From: Sage Weil Date: Tue, 6 Oct 2015 19:08:57 +0000 (-0400) Subject: msg: track stamp of last keepalive[2] received X-Git-Tag: v10.0.1~26^2~33 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb9dfada02e61928b3b63e0c2794c1885021180f;p=ceph.git msg: track stamp of last keepalive[2] received Signed-off-by: Sage Weil --- diff --git a/src/msg/Connection.h b/src/msg/Connection.h index 1539b39100de..d54b7d6e7eff 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -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 ConnectionRef; diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 71e493198940..57dd9d5a3b54 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -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; diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc index d1483785de7c..f14da82e9f00 100644 --- a/src/msg/simple/Pipe.cc +++ b/src/msg/simple/Pipe.cc @@ -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; }