]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: check front_msg correctly during sweep
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 5 Jul 2019 10:34:05 +0000 (18:34 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 5 Jul 2019 13:53:39 +0000 (21:53 +0800)
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 <yingxin.cheng@intel.com>
src/crimson/net/Protocol.cc

index 3ef6cc9612f497c1af9802047d83558adbada4b3..31ec925f812f2800573cd4fe1c0b091987652fad 100644 (file)
@@ -101,19 +101,19 @@ seastar::future<stop_t> 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);