]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: explicitly discard future from with_gate()
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 11 Sep 2019 05:51:24 +0000 (13:51 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 18 Sep 2019 04:32:31 +0000 (12:32 +0800)
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 <yingxin.cheng@intel.com>
src/crimson/mgr/client.cc
src/crimson/mon/MonClient.cc
src/crimson/net/Protocol.cc
src/crimson/net/ProtocolV1.cc
src/crimson/net/ProtocolV2.cc

index fd8e917d0c87bf3ae6ae88f092b1eaceab305fdc..4a29c6198bca1561bc75c9f2006166f39ed8c7d7 100644 (file)
@@ -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()) {
index 2c236af718bd210ed2397acf483bfa949b2f5c90..fff3597ae9fbe75d9ae08b75032c3162639e3860 100644 (file)
@@ -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(),
index 15c618a64a5d6e93eec4ec12b87e62a4c855e96e..c7350fa445e8cdadda432174528444cf70a2e865 100644 (file)
@@ -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 {}",
index 13e5fe3e73f620f38b2bfa204768bc512bfd72f2..39418899799eefb9a7b8bed936b1304f279d5c76 100644 (file)
@@ -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<SocketConnection>(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<SocketConnection>(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) {
index b936342b5283179ccbde5a6559c4beb80cab3cfb..07fa0a4eab20e227059e0cbd8b7f60de0bbcd7bd 100644 (file)
@@ -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<SocketConnection>(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<SocketConnection>(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<SocketConnection>(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<AuthConnectionMeta>();
@@ -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<SocketConnection>(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<SocketConnection>(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);