From: Yingxin Cheng Date: Fri, 21 Jul 2023 03:12:25 +0000 (+0800) Subject: crimson/net: don't miss keepalive during message sweeping X-Git-Tag: v19.0.0~627^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9bf4eeaa923351dc8f53b7cc3a02c2e8483c054e;p=ceph.git 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 --- diff --git a/src/crimson/net/io_handler.cc b/src/crimson/net/io_handler.cc index 576f9ff434c9..8b774e678b79 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);