From c2a65d606b3a6da7d29a9deff347b8b06fcc947d Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Fri, 21 Jul 2023 11:12:25 +0800 Subject: [PATCH] crimson/net: don't miss keepalive during message sweeping The flags need to be updated atomically to prevent missing them during message sweeping. Signed-off-by: Yingxin Cheng (cherry picked from commit 9bf4eeaa923351dc8f53b7cc3a02c2e8483c054e) --- src/crimson/net/io_handler.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/crimson/net/io_handler.cc b/src/crimson/net/io_handler.cc index 576f9ff434c9c..8b774e678b791 100644 --- a/src/crimson/net/io_handler.cc +++ b/src/crimson/net/io_handler.cc @@ -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( 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( ).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::no); -- 2.39.5