From: Yingxin Cheng Date: Fri, 5 Jul 2019 10:34:05 +0000 (+0800) Subject: crimson/net: check front_msg correctly during sweep X-Git-Tag: v15.1.0~2283^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f763d496035d2e1276bb0547cd65af37f0732c7d;p=ceph.git crimson/net: check front_msg correctly during sweep In order to check whether the front_msg is unchanged, we need to make sure: * The sent message is not reused; * The message to be checked is not freed; Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index 3ef6cc9612f4..31ec925f812f 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -101,19 +101,19 @@ seastar::future Protocol::do_write_dispatch_sweep() size_t num_msgs = conn.out_q.size(); // we must have something to write... ceph_assert(num_msgs || need_keepalive || keepalive_ack.has_value()); - Message* msg_ptr = nullptr; + MessageRef front_msg; if (likely(num_msgs)) { - msg_ptr = conn.out_q.front().get(); + front_msg = conn.out_q.front(); } // sweep all pending writes with the concrete Protocol return socket->write(do_sweep_messages( conn.out_q, num_msgs, need_keepalive, keepalive_ack)) - .then([this, msg_ptr, num_msgs, prv_keepalive_ack=keepalive_ack] { + .then([this, front_msg, num_msgs, prv_keepalive_ack=keepalive_ack] { need_keepalive = false; if (keepalive_ack == prv_keepalive_ack) { keepalive_ack = std::nullopt; } - if (likely(num_msgs && msg_ptr == conn.out_q.front().get())) { + if (likely(num_msgs && front_msg == conn.out_q.front())) { // we have sent some messages successfully // and the out_q was not reset during socket write conn.out_q.erase(conn.out_q.begin(), conn.out_q.begin()+num_msgs);