From 0e91db70acb5b4295701d12d6e559d20e9ab2cea Mon Sep 17 00:00:00 2001 From: liupengs Date: Sun, 1 Mar 2020 13:04:37 +0800 Subject: [PATCH] msg/async/rdma: move C_handle_connection to RDMAConnectionSocketImpl.cc Signed-off-by: Peng Liu (cherry picked from commit 9fbe5bc75496ab58d075b724078979e30063b623) Conflicts: src/msg/async/rdma/RDMAConnectedSocketImpl.cc - use the constructor of RDMAConnectedSocketImpl in nautilus --- src/msg/async/rdma/RDMAConnectedSocketImpl.cc | 27 ++++++++++++++----- src/msg/async/rdma/RDMAStack.h | 17 +----------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/msg/async/rdma/RDMAConnectedSocketImpl.cc b/src/msg/async/rdma/RDMAConnectedSocketImpl.cc index a2c072a035ed..89be742811c5 100644 --- a/src/msg/async/rdma/RDMAConnectedSocketImpl.cc +++ b/src/msg/async/rdma/RDMAConnectedSocketImpl.cc @@ -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 @@ -38,7 +51,7 @@ RDMAConnectedSocketImpl::RDMAConnectedSocketImpl(CephContext *cct, Infiniband* i RDMAWorker *w) : cct(cct), connected(0), error(0), infiniband(ib), dispatcher(s), worker(w), lock("RDMAConnectedSocketImpl::lock"), - 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) { @@ -241,7 +254,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; } @@ -657,13 +670,13 @@ void RDMAConnectedSocketImpl::fin() { } void RDMAConnectedSocketImpl::cleanup() { - if (con_handler && tcp_fd >= 0) { - (static_cast(con_handler))->close(); + if (read_handler && tcp_fd >= 0) { + (static_cast(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(established_handler))->close(); @@ -714,7 +727,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); } diff --git a/src/msg/async/rdma/RDMAStack.h b/src/msg/async/rdma/RDMAStack.h index 3b6ed4e038c1..e4d34ee079ec 100644 --- a/src/msg/async/rdma/RDMAStack.h +++ b/src/msg/async/rdma/RDMAStack.h @@ -196,7 +196,7 @@ class RDMAConnectedSocketImpl : public ConnectedSocketImpl { Mutex lock; std::vector wc; bool is_server; - EventCallbackRef con_handler; + EventCallbackRef read_handler; EventCallbackRef established_handler; int tcp_fd = -1; bool active;// qp is active ? @@ -237,21 +237,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 { -- 2.47.3