Skip to content

Commit 0b849d1

Browse files
committed
Deallocate polling cq
1 parent ea03983 commit 0b849d1

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/brpc/rdma/rdma_endpoint.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,14 +1298,11 @@ int RdmaEndpoint::BringUpQp(uint16_t lid, ibv_gid gid, uint32_t qp_num) {
12981298
return 0;
12991299
}
13001300

1301-
void RdmaEndpoint::DeallocateCq(ibv_cq* cq, unsigned int cq_events) {
1301+
void DeallocateCq(ibv_cq* cq) {
13021302
if (NULL == cq) {
13031303
return;
13041304
}
13051305

1306-
if (cq_events > 0) {
1307-
IbvAckCqEvents(cq, cq_events);
1308-
}
13091306
int err = IbvDestroyCq(cq);
13101307
LOG_IF(WARNING, 0 != err) << "Fail to destroy CQ: " << berror(err);
13111308
}
@@ -1328,6 +1325,13 @@ void RdmaEndpoint::DeallocateResources() {
13281325
}
13291326
}
13301327

1328+
if (NULL != _resource->send_cq) {
1329+
IbvAckCqEvents(_resource->send_cq, _send_cq_events);
1330+
}
1331+
if (NULL != _resource->recv_cq) {
1332+
IbvAckCqEvents(_resource->recv_cq, _recv_cq_events);
1333+
}
1334+
13311335
bool remove_consumer = true;
13321336
if (!move_to_rdma_resource_list) {
13331337
if (NULL != _resource->qp) {
@@ -1336,8 +1340,9 @@ void RdmaEndpoint::DeallocateResources() {
13361340
_resource->qp = NULL;
13371341
}
13381342

1339-
DeallocateCq(_resource->send_cq, _send_cq_events);
1340-
DeallocateCq(_resource->recv_cq, _recv_cq_events);
1343+
DeallocateCq(_resource->polling_cq);
1344+
DeallocateCq(_resource->send_cq);
1345+
DeallocateCq(_resource->recv_cq);
13411346

13421347
if (NULL != _resource->comp_channel) {
13431348
// Destroy send_comp_channel will destroy this fd,
@@ -1369,12 +1374,6 @@ void RdmaEndpoint::DeallocateResources() {
13691374
}
13701375

13711376
if (move_to_rdma_resource_list) {
1372-
if (NULL != _resource->send_cq) {
1373-
IbvAckCqEvents(_resource->send_cq, _send_cq_events);
1374-
}
1375-
if (NULL != _resource->recv_cq) {
1376-
IbvAckCqEvents(_resource->recv_cq, _recv_cq_events);
1377-
}
13781377
BAIDU_SCOPED_LOCK(*g_rdma_resource_mutex);
13791378
_resource->next = g_rdma_resource_list;
13801379
g_rdma_resource_list = _resource;

src/brpc/rdma/rdma_endpoint.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ friend class Socket;
134134
// Process handshake at the server
135135
static void* ProcessHandshakeAtServer(void* arg);
136136

137-
// Deallocate CQ resource.
138-
static void DeallocateCq(ibv_cq* cq, unsigned int cq_events);
139-
140137
// Allocate resources
141138
// Return 0 if success, -1 if failed and errno set
142139
int AllocateResources();
@@ -277,8 +274,6 @@ friend class Socket;
277274
butil::atomic<uint16_t> _sq_window_size;
278275
// The number of new WRs posted in the local Recv Queue
279276
butil::atomic<uint16_t> _new_rq_wrs;
280-
// The number of inflight send IMM.
281-
butil::atomic<uint16_t> _imm_inflight;
282277

283278
// butex for inform read events on TCP fd during handshake
284279
butil::atomic<int> *_read_butex;

test/brpc_rdma_unittest.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_magic_str) {
209209

210210
uint8_t data[RDMA_HELLO_MSG_LEN];
211211
memcpy(data, "PRPC", 4); // send as normal baidu_std protocol
212-
memset(data + 4, 0, 32);
213-
ASSERT_EQ(38, write(sockfd, data, 38));
212+
ASSERT_EQ(4, write(sockfd, data, 4));
214213
usleep(100000); // wait for server to handle the msg
215214
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, s->_rdma_ep->_state);
216215

@@ -660,9 +659,6 @@ TEST_F(RdmaTest, client_send_data_on_tcp_after_ack_send) {
660659
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, s->_rdma_ep->_state);
661660
ASSERT_EQ(sizeof(flags), write(sockfd1, &flags, sizeof(flags)));
662661
usleep(100000);
663-
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, s->_rdma_ep->_state);
664-
close(sockfd1);
665-
usleep(100000); // wait for server to handle the msg
666662
ASSERT_EQ(NULL, GetSocketFromServer(0));
667663

668664
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));

0 commit comments

Comments
 (0)