From: Yingxin Cheng Date: Wed, 11 Sep 2019 05:51:24 +0000 (+0800) Subject: crimson/net: explicitly discard future from with_gate() X-Git-Tag: v15.1.0~1515^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16f2d7558264552ccc6868eee0108e180035551d;p=ceph.git crimson/net: explicitly discard future from with_gate() We are using with_gate() to wrap a slow operation when we want to start it but don't want/need to wait it to be finished in the same function. In this case, the future returned from with_gate() is discarded, and we need to make sure there is another continuation responsible to waiting for the gate closed. Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/mgr/client.cc b/src/crimson/mgr/client.cc index fd8e917d0c87..4a29c6198bca 100644 --- a/src/crimson/mgr/client.cc +++ b/src/crimson/mgr/client.cc @@ -117,7 +117,7 @@ seastar::future<> Client::handle_mgr_conf(ceph::net::Connection* conn, void Client::report() { - seastar::with_gate(gate, [this] { + (void) seastar::with_gate(gate, [this] { auto pg_stats = with_stats.get_stats(); return conn->send(std::move(pg_stats)).finally([this] { if (report_period.count()) { diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index 2c236af718bd..fff3597ae9fb 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -500,7 +500,7 @@ seastar::future<> Client::load_keyring() void Client::tick() { - seastar::with_gate(tick_gate, [this] { + (void) seastar::with_gate(tick_gate, [this] { if (active_con) { return seastar::when_all_succeed(active_con->get_conn()->keepalive(), active_con->renew_tickets(), diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index 15c618a64a5d..c7350fa445e8 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -272,7 +272,7 @@ void Protocol::write_event() case write_state_t::open: [[fallthrough]]; case write_state_t::delay: - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return do_write_dispatch_sweep( ).handle_exception([this] (std::exception_ptr eptr) { logger().error("{} do_write_dispatch_sweep(): unexpected exception {}", diff --git a/src/crimson/net/ProtocolV1.cc b/src/crimson/net/ProtocolV1.cc index 13e5fe3e73f6..39418899799e 100644 --- a/src/crimson/net/ProtocolV1.cc +++ b/src/crimson/net/ProtocolV1.cc @@ -318,7 +318,7 @@ void ProtocolV1::start_connect(const entity_addr_t& _peer_addr, conn.policy = messenger.get_policy(_peer_type); messenger.register_conn( seastar::static_pointer_cast(conn.shared_from_this())); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return Socket::connect(conn.peer_addr) .then([this](SocketFRef sock) { socket = std::move(sock); @@ -621,7 +621,7 @@ void ProtocolV1::start_accept(SocketFRef&& sock, socket = std::move(sock); messenger.accept_conn( seastar::static_pointer_cast(conn.shared_from_this())); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { // stop learning my_addr before sending it out, so it won't change return messenger.learned_addr(messenger.get_myaddr(), conn).then([this] { // encode/send server's handshake header @@ -849,7 +849,7 @@ seastar::future<> ProtocolV1::read_message() } // start dispatch, ignoring exceptions from the application layer - seastar::with_gate(pending_dispatch, [this, msg = std::move(msg_ref)] { + (void) seastar::with_gate(pending_dispatch, [this, msg = std::move(msg_ref)] { logger().debug("{} <== #{} === {} ({})", conn, msg->get_seq(), *msg, msg->get_type()); return dispatcher.ms_dispatch(&conn, std::move(msg)) @@ -896,7 +896,7 @@ void ProtocolV1::execute_open() state = state_t::open; set_write_state(write_state_t::open); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { // start background processing of tags return handle_tags() .handle_exception_type([this] (const std::system_error& e) { diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index b936342b5283..07fa0a4eab20 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -464,7 +464,7 @@ void ProtocolV2::fault(bool backoff, const char* func_name, std::exception_ptr e void ProtocolV2::dispatch_reset() { - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return dispatcher.ms_handle_reset( seastar::static_pointer_cast(conn.shared_from_this())); }).handle_exception([this] (std::exception_ptr eptr) { @@ -482,7 +482,7 @@ void ProtocolV2::reset_session(bool full) client_cookie = generate_client_cookie(); peer_global_seq = 0; reset_write(); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return dispatcher.ms_handle_remote_reset( seastar::static_pointer_cast(conn.shared_from_this())); }).handle_exception([this] (std::exception_ptr eptr) { @@ -917,7 +917,7 @@ void ProtocolV2::execute_connecting() abort_protocol(); } if (socket) { - with_gate(pending_dispatch, [this, sock = std::move(socket)] () mutable { + (void) with_gate(pending_dispatch, [this, sock = std::move(socket)] () mutable { return sock->close().then([sock = std::move(sock)] {}); }); } @@ -976,7 +976,7 @@ void ProtocolV2::execute_connecting() } switch (next) { case next_step_t::ready: { - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return dispatcher.ms_handle_connect( seastar::static_pointer_cast(conn.shared_from_this())); }).handle_exception([this] (std::exception_ptr eptr) { @@ -1539,7 +1539,7 @@ ProtocolV2::server_reconnect() void ProtocolV2::execute_accepting() { trigger_state(state_t::ACCEPTING, write_state_t::none, false); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return seastar::futurize_apply([this] { INTERCEPT_N_RW(custom_bp_t::SOCKET_ACCEPTED); auth_meta = seastar::make_lw_shared(); @@ -1644,7 +1644,7 @@ seastar::future<> ProtocolV2::finish_auth() void ProtocolV2::execute_establishing() { trigger_state(state_t::ESTABLISHING, write_state_t::delay, false); - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return dispatcher.ms_handle_accept( seastar::static_pointer_cast(conn.shared_from_this())); }).handle_exception([this] (std::exception_ptr eptr) { @@ -1749,23 +1749,23 @@ void ProtocolV2::trigger_replacing(bool reconnect, if (socket) { socket->shutdown(); } - seastar::with_gate(pending_dispatch, [this] { + (void) seastar::with_gate(pending_dispatch, [this] { return dispatcher.ms_handle_accept( seastar::static_pointer_cast(conn.shared_from_this())); }).handle_exception([this] (std::exception_ptr eptr) { logger().error("{} ms_handle_accept caught exception: {}", conn, eptr); ceph_abort("unexpected exception from ms_handle_accept()"); }); - seastar::with_gate(pending_dispatch, - [this, - reconnect, - do_reset, - new_socket = std::move(new_socket), - new_auth_meta = std::move(new_auth_meta), - new_rxtx = std::move(new_rxtx), - new_client_cookie, new_peer_name, - new_conn_features, new_peer_global_seq, - new_connect_seq, new_msg_seq] () mutable { + (void) seastar::with_gate(pending_dispatch, + [this, + reconnect, + do_reset, + new_socket = std::move(new_socket), + new_auth_meta = std::move(new_auth_meta), + new_rxtx = std::move(new_rxtx), + new_client_cookie, new_peer_name, + new_conn_features, new_peer_global_seq, + new_connect_seq, new_msg_seq] () mutable { return wait_write_exit().then([this, do_reset] { if (do_reset) { reset_session(true); @@ -1787,7 +1787,7 @@ void ProtocolV2::trigger_replacing(bool reconnect, } if (socket) { - with_gate(pending_dispatch, [this, sock = std::move(socket)] () mutable { + (void) with_gate(pending_dispatch, [this, sock = std::move(socket)] () mutable { return sock->close().then([sock = std::move(sock)] {}); }); } @@ -1974,7 +1974,7 @@ seastar::future<> ProtocolV2::read_message(utime_t throttle_stamp) // TODO: change MessageRef with seastar::shared_ptr auto msg_ref = MessageRef{message, false}; - seastar::with_gate(pending_dispatch, [this, msg = std::move(msg_ref)] { + (void) seastar::with_gate(pending_dispatch, [this, msg = std::move(msg_ref)] { return dispatcher.ms_dispatch(&conn, std::move(msg)); }).handle_exception([this] (std::exception_ptr eptr) { logger().error("{} ms_dispatch caught exception: {}", conn, eptr);