]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: SERVER_WAIT state for accepting server
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 8 Aug 2019 08:35:13 +0000 (16:35 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 12 Aug 2019 09:22:45 +0000 (17:22 +0800)
Server wait for peer client close the socket at SERVER_WAIT.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/ProtocolV2.cc
src/crimson/net/ProtocolV2.h

index 901158b8751c1e0896cc157a9b4dbb0e907f5295..a39df77489a1b1c44350e1803cb26f6b4165a12f 100644 (file)
@@ -1785,16 +1785,24 @@ void ProtocolV2::execute_wait()
 
 void ProtocolV2::execute_server_wait()
 {
-  // TODO not implemented
-  // trigger_state(state_t::SERVER_WAIT, write_state_t::delay, false);
-  ceph_assert(false);
+  trigger_state(state_t::SERVER_WAIT, write_state_t::delay, false);
+  execution_done = seastar::with_gate(pending_dispatch, [this] {
+    return read_exactly(1).then([this] (auto bl) {
+      logger().warn("{} SERVER_WAIT got read, abort", conn);
+      abort_in_fault();
+    }).handle_exception([this] (std::exception_ptr eptr) {
+      logger().debug("{} execute_server_wait(): got exception {} at state {}",
+                     conn, eptr, get_state_name(state));
+      close();
+    });
+  });
 }
 
 // CLOSING state
 
 void ProtocolV2::trigger_close()
 {
-  if (state == state_t::ACCEPTING) {
+  if (state == state_t::ACCEPTING || state == state_t::SERVER_WAIT) {
     messenger.unaccept_conn(
       seastar::static_pointer_cast<SocketConnection>(
         conn.shared_from_this()));
index ed880a57f325d6ff773eb8daf19b989552181fb5..509b18c77de86f4231dc16d96cd4dbbe83afac17 100644 (file)
@@ -40,11 +40,11 @@ class ProtocolV2 final : public Protocol {
   enum class state_t {
     NONE = 0,
     ACCEPTING,
+    SERVER_WAIT,
     CONNECTING,
     READY,
     STANDBY,
     WAIT,           // ? CLIENT_WAIT
-    SERVER_WAIT,    // ?
     REPLACING,      // ?
     CLOSING
   };
@@ -53,11 +53,11 @@ class ProtocolV2 final : public Protocol {
   static const char *get_state_name(state_t state) {
     const char *const statenames[] = {"NONE",
                                       "ACCEPTING",
+                                      "SERVER_WAIT",
                                       "CONNECTING",
                                       "READY",
                                       "STANDBY",
                                       "WAIT",           // ? CLIENT_WAIT
-                                      "SERVER_WAIT",    // ?
                                       "REPLACING",      // ?
                                       "CLOSING"};
     return statenames[static_cast<int>(state)];