From eabd41ac2cce791a57f9ad5e8c5214d8f06d30ff Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Tue, 15 Dec 2020 15:45:52 +0800 Subject: [PATCH] crimson/net: assert connection gate is not unexpectedly closed Signed-off-by: Yingxin Cheng --- src/crimson/net/Protocol.cc | 2 ++ src/crimson/net/ProtocolV1.cc | 1 + src/crimson/net/ProtocolV2.cc | 1 + 3 files changed, 4 insertions(+) diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index 6973aa5df5b..4c9c1846ce9 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -70,6 +70,7 @@ void Protocol::close(bool dispatch_reset, socket->shutdown(); } set_write_state(write_state_t::drop); + assert(!gate.is_closed()); auto gate_closed = gate.close(); if (dispatch_reset) { @@ -306,6 +307,7 @@ void Protocol::write_event() case write_state_t::open: [[fallthrough]]; case write_state_t::delay: + assert(!gate.is_closed()); gate.dispatch_in_background("do_write_dispatch_sweep", *this, [this] { return do_write_dispatch_sweep(); }); diff --git a/src/crimson/net/ProtocolV1.cc b/src/crimson/net/ProtocolV1.cc index 34fb14573e2..bf7cd633880 100644 --- a/src/crimson/net/ProtocolV1.cc +++ b/src/crimson/net/ProtocolV1.cc @@ -316,6 +316,7 @@ void ProtocolV1::start_connect(const entity_addr_t& _peer_addr, set_write_state(write_state_t::delay); ceph_assert(!socket); + ceph_assert(!gate.is_closed()); conn.peer_addr = _peer_addr; conn.target_addr = _peer_addr; conn.set_peer_name(_peer_name); diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 4d7d06d7a33..bf9224b1712 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -164,6 +164,7 @@ void ProtocolV2::start_connect(const entity_addr_t& _peer_addr, { ceph_assert(state == state_t::NONE); ceph_assert(!socket); + ceph_assert(!gate.is_closed()); conn.peer_addr = _peer_addr; conn.target_addr = _peer_addr; conn.set_peer_name(_peer_name); -- 2.47.3