]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: don't schedule/execute send/keepalive when closing
authorYingxin <yingxin.cheng@intel.com>
Fri, 28 Dec 2018 02:55:00 +0000 (10:55 +0800)
committerYingxin Cheng <yingxincheng@gmail.com>
Fri, 4 Jan 2019 06:06:21 +0000 (14:06 +0800)
Signed-off-by: Yingxin <yingxin.cheng@intel.com>
src/crimson/net/SocketConnection.cc

index cf1d5cd591d752c5492314931b75ce44f1be6027..23765345369141cef21ef870115ffbcca146c798 100644 (file)
@@ -68,6 +68,8 @@ bool SocketConnection::is_connected()
 
 seastar::future<> SocketConnection::send(MessageRef msg)
 {
+  if (state == state_t::closing)
+    return seastar::now();
   return seastar::with_gate(pending_dispatch, [this, msg=std::move(msg)] {
       return do_send(std::move(msg))
         .handle_exception([this] (std::exception_ptr eptr) {
@@ -79,6 +81,8 @@ seastar::future<> SocketConnection::send(MessageRef msg)
 
 seastar::future<> SocketConnection::keepalive()
 {
+  if (state == state_t::closing)
+    return seastar::now();
   return seastar::with_gate(pending_dispatch, [this] {
       return do_keepalive()
         .handle_exception([this] (std::exception_ptr eptr) {
@@ -285,6 +289,8 @@ seastar::future<> SocketConnection::do_send(MessageRef msg)
   // TODO: retry send for lossless connection
   seastar::shared_future<> f = send_ready.then(
     [this, msg = std::move(msg)] {
+      if (state == state_t::closing)
+        return seastar::now();
       return write_message(std::move(msg));
     });
 
@@ -298,6 +304,8 @@ seastar::future<> SocketConnection::do_keepalive()
 {
   // TODO: retry keepalive for lossless connection
   seastar::shared_future<> f = send_ready.then([this] {
+      if (state == state_t::closing)
+        return seastar::now();
       k.req.stamp = ceph::coarse_real_clock::to_ceph_timespec(
         ceph::coarse_real_clock::now());
       return socket->write_flush(make_static_packet(k.req));