From 467571972b23c938789195a869dc3716efc9c4e2 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Tue, 15 Jan 2019 15:33:34 +0000 Subject: [PATCH] msg/async: msgr2: fix keepalive_ack message Signed-off-by: Ricardo Dias --- src/msg/async/ProtocolV2.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 4bfe17b984d..4689943f9eb 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -375,6 +375,14 @@ struct KeepAliveFrame : public SignedEncryptedFrame { inline utime_t ×tamp() { return get_val<0>(); } }; +struct KeepAliveFrameAck + : public SignedEncryptedFrame { + const ProtocolV2::Tag tag = ProtocolV2::Tag::KEEPALIVE2_ACK; + using SignedEncryptedFrame::SignedEncryptedFrame; + + inline utime_t ×tamp() { return get_val<0>(); } +}; + struct AckFrame : public SignedEncryptedFrame { const ProtocolV2::Tag tag = ProtocolV2::Tag::ACK; using SignedEncryptedFrame::SignedEncryptedFrame; @@ -735,7 +743,7 @@ void ProtocolV2::send_message(Message *m) { void ProtocolV2::send_keepalive() { ldout(cct, 10) << __func__ << dendl; std::lock_guard l(connection->write_lock); - if (can_write) { + if (state != CLOSED) { keepalive = true; connection->center->dispatch_event_external(connection->write_handler); } @@ -868,7 +876,7 @@ void ProtocolV2::append_keepalive() { } void ProtocolV2::append_keepalive_ack(utime_t ×tamp) { - KeepAliveFrame keepalive_ack_frame(this, timestamp); + KeepAliveFrameAck keepalive_ack_frame(this, timestamp); connection->outcoming_bl.claim_append(keepalive_ack_frame.get_buffer()); } @@ -1988,7 +1996,7 @@ CtPtr ProtocolV2::handle_keepalive2(char *payload, uint32_t length) { CtPtr ProtocolV2::handle_keepalive2_ack(char *payload, uint32_t length) { ldout(cct, 20) << __func__ << " payload_len=" << length << dendl; - KeepAliveFrame keepalive_ack_frame(this, payload, length); + KeepAliveFrameAck keepalive_ack_frame(this, payload, length); connection->set_last_keepalive_ack(keepalive_ack_frame.timestamp()); ldout(cct, 20) << __func__ << " got KEEPALIVE_ACK" << dendl; -- 2.39.5