]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: don't miss keepalive during message sweeping
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 21 Jul 2023 03:12:25 +0000 (11:12 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 19 Oct 2023 07:15:14 +0000 (07:15 +0000)
The flags need to be updated atomically to prevent missing them during
message sweeping.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
(cherry picked from commit 9bf4eeaa923351dc8f53b7cc3a02c2e8483c054e)

src/crimson/net/io_handler.cc

index 576f9ff434c9c3fd3802815bad14decd7ebd5183..8b774e678b7912291b4dc678cfaa2c59b6444c02 100644 (file)
@@ -791,12 +791,17 @@ IOHandler::do_out_dispatch(shard_states_t &ctx)
         });
       }
 
+      auto require_keepalive = need_keepalive;
+      need_keepalive = false;
+      auto maybe_keepalive_ack = next_keepalive_ack;
+      next_keepalive_ack = std::nullopt;
       auto to_ack = ack_left;
       assert(to_ack == 0 || in_seq > 0);
+      ack_left = 0;
       return frame_assembler->write<false>(
         sweep_out_pending_msgs_to_sent(
-          need_keepalive, next_keepalive_ack, to_ack > 0)
-      ).then([this, prv_keepalive_ack=next_keepalive_ack, to_ack, &ctx] {
+          require_keepalive, maybe_keepalive_ack, to_ack > 0)
+      ).then([this, &ctx] {
         if (ctx.get_io_state() != io_state_t::open) {
           return frame_assembler->flush<false>(
           ).then([] {
@@ -804,13 +809,6 @@ IOHandler::do_out_dispatch(shard_states_t &ctx)
           });
         }
 
-        need_keepalive = false;
-        if (next_keepalive_ack == prv_keepalive_ack) {
-          next_keepalive_ack = std::nullopt;
-        }
-        assert(ack_left >= to_ack);
-        ack_left -= to_ack;
-
         // FIXME: may leak a flush if state is changed after return and before
         // the next repeat body.
         return seastar::make_ready_future<stop_t>(stop_t::no);