Skip to content

Commit

Permalink
fix bug: QP cannot be put back to QP pool (#2036)
Browse files Browse the repository at this point in the history
* return 0 for append_user_data_with_meta when size=0

* fix bug: QP cannot be put back to QP pool
  • Loading branch information
Tuvie committed Dec 6, 2022
1 parent a39db73 commit 8efcf9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/brpc/rdma/rdma_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,8 @@ void RdmaEndpoint::DeallocateResources() {
}
bool move_to_rdma_resource_list = false;
if (_sq_size <= FLAGS_rdma_prepared_qp_size &&
_rq_size <= FLAGS_rdma_prepared_qp_size) {
_rq_size <= FLAGS_rdma_prepared_qp_size &&
FLAGS_rdma_prepared_qp_cnt > 0) {
ibv_qp_attr attr;
attr.qp_state = IBV_QPS_RESET;
if (IbvModifyQp(_resource->qp, &attr, IBV_QP_STATE) == 0) {
Expand All @@ -1224,12 +1225,14 @@ void RdmaEndpoint::DeallocateResources() {
if (IbvDestroyQp(_resource->qp) < 0) {
PLOG(WARNING) << "Fail to destroy QP";
}
_resource->qp = NULL;
}
if (_resource->cq) {
IbvAckCqEvents(_resource->cq, _cq_events);
if (IbvDestroyCq(_resource->cq) < 0) {
PLOG(WARNING) << "Fail to destroy CQ";
}
_resource->cq = NULL;
}
if (_resource->comp_channel) {
// destroy comp_channel will destroy this fd
Expand All @@ -1239,8 +1242,10 @@ void RdmaEndpoint::DeallocateResources() {
if (IbvDestroyCompChannel(_resource->comp_channel) < 0) {
PLOG(WARNING) << "Fail to destroy CQ channel";
}
_resource->comp_channel = NULL;
}
delete _resource;
_resource = NULL;
}

SocketUniquePtr s;
Expand All @@ -1256,7 +1261,7 @@ void RdmaEndpoint::DeallocateResources() {
_cq_sid = INVALID_SOCKET_ID;
}

if (!move_to_rdma_resource_list) {
if (move_to_rdma_resource_list) {
if (_resource->cq) {
IbvAckCqEvents(_resource->cq, _cq_events);
}
Expand Down
4 changes: 0 additions & 4 deletions src/butil/iobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,10 +1217,6 @@ int IOBuf::append_user_data_with_meta(void* data,
size_t size,
void (*deleter)(void*),
uint64_t meta) {
if (size == 0) {
LOG(WARNING) << "data_size should not be 0";
return -1;
}
if (size > 0xFFFFFFFFULL - 100) {
LOG(FATAL) << "data_size=" << size << " is too large";
return -1;
Expand Down

0 comments on commit 8efcf9c

Please sign in to comment.