]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/rdma: move C_handle_connection to RDMAConnectionSocketImpl.cc 31109/head
authorliupengs <liupeng37@baidu.com>
Sun, 1 Mar 2020 05:04:37 +0000 (13:04 +0800)
committerliupengs <liupeng37@baidu.com>
Sun, 1 Mar 2020 06:17:39 +0000 (14:17 +0800)
Signed-off-by: Peng Liu <liupeng37@baidu.com>
src/msg/async/rdma/RDMAConnectedSocketImpl.cc
src/msg/async/rdma/RDMAStack.h

index d5a3f72c77a26f7a688dc32ae338c9a12e89aba7..97c5e2b143af0577bc5605a39b58fcd44abae142 100644 (file)
@@ -29,6 +29,19 @@ class C_handle_connection_established : public EventCallback {
   }
 };
 
+class C_handle_connection_read : public EventCallback {
+  RDMAConnectedSocketImpl *csi;
+  bool active = true;
+ public:
+  explicit C_handle_connection_read(RDMAConnectedSocketImpl *w): csi(w) {}
+  void do_request(uint64_t fd) final {
+    if (active)
+      csi->handle_connection();
+  }
+  void close() {
+    active = false;
+  }
+};
 
 #define dout_subsys ceph_subsys_ms
 #undef dout_prefix
@@ -39,7 +52,7 @@ RDMAConnectedSocketImpl::RDMAConnectedSocketImpl(CephContext *cct, shared_ptr<In
                                                  RDMAWorker *w)
   : cct(cct), connected(0), error(0), ib(ib),
     dispatcher(rdma_dispatcher), worker(w),
-    is_server(false), con_handler(new C_handle_connection(this)),
+    is_server(false), read_handler(new C_handle_connection_read(this)),
     established_handler(new C_handle_connection_established(this)),
     active(false), pending(false)
 {
@@ -169,7 +182,7 @@ int RDMAConnectedSocketImpl::handle_connection_established(bool need_set_fault)
     }
     return r;
   }
-  worker->center.create_file_event(tcp_fd, EVENT_READABLE, con_handler);
+  worker->center.create_file_event(tcp_fd, EVENT_READABLE, read_handler);
   ldout(cct, 20) << __func__ << " finish " << dendl;
   return 0;
 }
@@ -563,13 +576,13 @@ void RDMAConnectedSocketImpl::fin() {
 }
 
 void RDMAConnectedSocketImpl::cleanup() {
-  if (con_handler && tcp_fd >= 0) {
-    (static_cast<C_handle_connection*>(con_handler))->close();
+  if (read_handler && tcp_fd >= 0) {
+    (static_cast<C_handle_connection_read*>(read_handler))->close();
     worker->center.submit_to(worker->center.get_id(), [this]() {
       worker->center.delete_file_event(tcp_fd, EVENT_READABLE | EVENT_WRITABLE);
     }, false);
-    delete con_handler;
-    con_handler = nullptr;
+    delete read_handler;
+    read_handler = nullptr;
   }
   if (established_handler) {
     (static_cast<C_handle_connection_established*>(established_handler))->close();
@@ -614,7 +627,7 @@ void RDMAConnectedSocketImpl::set_accept_fd(int sd)
   tcp_fd = sd;
   is_server = true;
   worker->center.submit_to(worker->center.get_id(), [this]() {
-                          worker->center.create_file_event(tcp_fd, EVENT_READABLE, con_handler);
+                          worker->center.create_file_event(tcp_fd, EVENT_READABLE, read_handler);
                           }, true);
 }
 
index cd7a2904baeec5e7688180e1b55da64d6d928e0d..b7517600bf32da40d9570f441cdc21fe08b50d43 100644 (file)
@@ -188,7 +188,7 @@ class RDMAConnectedSocketImpl : public ConnectedSocketImpl {
   ceph::mutex lock = ceph::make_mutex("RDMAConnectedSocketImpl::lock");
   std::vector<ibv_wc> wc;
   bool is_server;
-  EventCallbackRef con_handler;
+  EventCallbackRef read_handler;
   EventCallbackRef established_handler;
   int tcp_fd = -1;
   bool active;// qp is active ?
@@ -234,21 +234,6 @@ class RDMAConnectedSocketImpl : public ConnectedSocketImpl {
   void set_pending(bool val) {pending = val;}
   void post_chunks_to_rq(int num);
   void update_post_backlog();
-
-  class C_handle_connection : public EventCallback {
-    RDMAConnectedSocketImpl *csi;
-    bool active;
-   public:
-    explicit C_handle_connection(RDMAConnectedSocketImpl *w): csi(w), active(true) {}
-    void do_request(uint64_t fd) {
-      if (active)
-        csi->handle_connection();
-    }
-    void close() {
-      active = false;
-    }
-  };
-  
 };
 
 enum RDMA_CM_STATUS {