From: Yingxin Cheng Date: Fri, 25 Nov 2022 02:05:18 +0000 (+0800) Subject: crimson/net: fix execution_done wait mechanism X-Git-Tag: v18.1.0~375^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f8fe2ad087df49fd0ca4afd369b7a69c6df3af70;p=ceph-ci.git crimson/net: fix execution_done wait mechanism * prepare the execution_done before the function is invoked, not after. * execution_done future doesn't need to be shared. Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 3f24fa0925d..083978dd96f 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -1640,7 +1640,9 @@ void ProtocolV2::trigger_replacing(bool reconnect, return wait_out_exit_dispatching( ).then([this] { protocol_timer.cancel(); - return execution_done.get_future(); + auto done = std::move(execution_done); + execution_done = seastar::now(); + return done; }).then([this, reconnect, do_reset, diff --git a/src/crimson/net/ProtocolV2.h b/src/crimson/net/ProtocolV2.h index 3c2b5e67434..d9216570b7a 100644 --- a/src/crimson/net/ProtocolV2.h +++ b/src/crimson/net/ProtocolV2.h @@ -108,13 +108,27 @@ class ProtocolV2 final : public Protocol { uint64_t peer_global_seq = 0; uint64_t connect_seq = 0; - seastar::shared_future<> execution_done = seastar::now(); + seastar::future<> execution_done = seastar::now(); template void gated_execute(const char* what, Func&& func) { gate.dispatch_in_background(what, *this, [this, &func] { - execution_done = seastar::futurize_invoke(std::forward(func)); - return execution_done.get_future(); + if (!execution_done.available()) { + // discard the unready future + gate.dispatch_in_background( + "gated_execute_abandon", + *this, + [fut=std::move(execution_done)]() mutable { + return std::move(fut); + } + ); + } + seastar::promise<> pr; + execution_done = pr.get_future(); + return seastar::futurize_invoke(std::forward(func) + ).finally([pr=std::move(pr)]() mutable { + pr.set_value(); + }); }); }