Wrap delete rdma_conn into destroy_rdma_conn

This commit is contained in:
Vitaliy Filippov
2026-05-18 01:17:56 +03:00
parent 648e3b12f0
commit ad24be717a
4 changed files with 25 additions and 26 deletions
+1
View File
@@ -259,6 +259,7 @@ protected:
bool init_recv_rdma(osd_client_t *cl); bool init_recv_rdma(osd_client_t *cl);
void handle_rdma_events(msgr_rdma_context_t *rdma_context); void handle_rdma_events(msgr_rdma_context_t *rdma_context);
msgr_rdma_context_t* choose_rdma_context(osd_client_t *cl); msgr_rdma_context_t* choose_rdma_context(osd_client_t *cl);
void destroy_rdma_conn(msgr_rdma_connection_t *rdma_conn);
#endif #endif
#ifdef WITH_RDMACM #ifdef WITH_RDMACM
void handle_rdmacm_events(); void handle_rdmacm_events();
+13
View File
@@ -794,3 +794,16 @@ void osd_messenger_t::handle_rdma_events(msgr_rdma_context_t *rdma_context)
} while (event_count > 0); } while (event_count > 0);
handle_immediate_ops(); handle_immediate_ops();
} }
void osd_messenger_t::destroy_rdma_conn(msgr_rdma_connection_t *rdma_conn)
{
if (rdma_conn->cmid)
{
auto rdma_it = rdmacm_connections.find(rdma_conn->cmid);
if (rdma_it != rdmacm_connections.end() && rdma_it->second->rdma_conn == rdma_conn)
{
rdmacm_connections.erase(rdma_it);
}
}
delete rdma_conn;
}
+7 -26
View File
@@ -5,9 +5,6 @@
#include <assert.h> #include <assert.h>
#include "messenger.h" #include "messenger.h"
#ifdef WITH_RDMA
#include "msgr_rdma.h"
#endif
void osd_client_t::cancel_ops() void osd_client_t::cancel_ops()
{ {
@@ -92,23 +89,11 @@ void osd_messenger_t::stop_client(uint64_t client_id, bool force_delete)
osd_peers.erase(osd_it); osd_peers.erase(osd_it);
} }
} }
#ifdef WITH_RDMA
if (cl->rdma_conn && cl->rdma_conn->cmid)
{
auto rdma_it = rdmacm_connections.find(cl->rdma_conn->cmid);
if (rdma_it != rdmacm_connections.end() && rdma_it->second == cl)
{
rdmacm_connections.erase(rdma_it);
}
}
#endif
#ifndef __MOCK__
if (cl->connect_timeout_id >= 0) if (cl->connect_timeout_id >= 0)
{ {
tfd->clear_timer(cl->connect_timeout_id); tfd->clear_timer(cl->connect_timeout_id);
cl->connect_timeout_id = -1; cl->connect_timeout_id = -1;
} }
#endif
if (cl->in_osd_num && break_pg_locks) if (cl->in_osd_num && break_pg_locks)
{ {
// Break PG locks // Break PG locks
@@ -143,9 +128,7 @@ void osd_messenger_t::destroy_client(osd_client_t *cl)
clients.erase(cl->client_id); clients.erase(cl->client_id);
if (cl->peer_fd >= 0) if (cl->peer_fd >= 0)
{ {
#ifndef __MOCK__
tfd->set_fd_handler(cl->peer_fd, false, NULL); tfd->set_fd_handler(cl->peer_fd, false, NULL);
#endif
for (auto rit = read_ready_clients.begin(); rit != read_ready_clients.end(); rit++) for (auto rit = read_ready_clients.begin(); rit != read_ready_clients.end(); rit++)
{ {
if (*rit == cl->client_id) if (*rit == cl->client_id)
@@ -164,6 +147,13 @@ void osd_messenger_t::destroy_client(osd_client_t *cl)
} }
clients_by_fd.erase(cl->peer_fd); clients_by_fd.erase(cl->peer_fd);
} }
#ifdef WITH_RDMA
if (cl->rdma_conn)
{
destroy_rdma_conn(cl->rdma_conn);
cl->rdma_conn = NULL;
}
#endif
delete cl; delete cl;
} }
@@ -196,13 +186,4 @@ osd_client_t::~osd_client_t()
delete op; delete op;
} }
} }
#ifndef __MOCK__
#ifdef WITH_RDMA
if (rdma_conn)
{
delete rdma_conn;
rdma_conn = NULL;
}
#endif
#endif
} }
+4
View File
@@ -57,3 +57,7 @@ json11::Json::object osd_messenger_t::merge_configs(const json11::Json::object &
{ {
return cli_config; return cli_config;
} }
void osd_messenger_t::destroy_rdma_conn(msgr_rdma_connection_t *rdma_conn)
{
}