This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 76c1f776 RdmaResource disallow copy and assign (#2206)
76c1f776 is described below
commit 76c1f776cdb4e979810a2c1f2425796166a93f67
Author: 372046933 <[email protected]>
AuthorDate: Fri Apr 21 10:23:37 2023 +0800
RdmaResource disallow copy and assign (#2206)
* RdmaResource disallow copy and assign
* Log error when IB register/deregister fails
* Fix log
---
src/brpc/rdma/rdma_endpoint.h | 1 +
src/brpc/rdma/rdma_helper.cpp | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/brpc/rdma/rdma_endpoint.h b/src/brpc/rdma/rdma_endpoint.h
index 663595a6..10f9a57a 100644
--- a/src/brpc/rdma/rdma_endpoint.h
+++ b/src/brpc/rdma/rdma_endpoint.h
@@ -58,6 +58,7 @@ struct RdmaResource {
RdmaResource* next;
RdmaResource();
~RdmaResource();
+ DISALLOW_COPY_AND_ASSIGN(RdmaResource);
};
class BAIDU_CACHELINE_ALIGNMENT RdmaEndpoint : public SocketUser {
diff --git a/src/brpc/rdma/rdma_helper.cpp b/src/brpc/rdma/rdma_helper.cpp
index d3eed99d..ef910706 100644
--- a/src/brpc/rdma/rdma_helper.cpp
+++ b/src/brpc/rdma/rdma_helper.cpp
@@ -545,6 +545,7 @@ void GlobalRdmaInitializeOrDie() {
uint32_t RegisterMemoryForRdma(void* buf, size_t len) {
ibv_mr* mr = IbvRegMr(g_pd, buf, len, IBV_ACCESS_LOCAL_WRITE);
if (!mr) {
+ PLOG(ERROR) << "Fail to register memory";
return 0;
}
{
@@ -556,7 +557,9 @@ uint32_t RegisterMemoryForRdma(void* buf, size_t len) {
return mr->lkey;
}
}
- IbvDeregMr(mr);
+ if(IbvDeregMr(mr)) {
+ PLOG(ERROR) << "Failed to deregister memory";
+ }
return 0;
}
@@ -571,7 +574,9 @@ void DeregisterMemoryForRdma(void* buf) {
}
}
if (mr) {
- IbvDeregMr(mr);
+ if (IbvDeregMr(mr)) {
+ PLOG(ERROR) << "Failed to deregister memory at: " << mr->addr;
+ }
} else {
LOG(WARNING) << "Try to deregister a buffer which is not registered";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]