Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librdmacm/cmtime: Rework of cmtime example #1448

Merged
merged 19 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
librdmacm/examples: Move error message for rdma_getaddrinfo to helper
Remove duplicate error messages printed after get_rdma_addr() into
the function.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
Sean Hefty committed Apr 9, 2024
commit b84e8ff031d03ee09f08fe568fbd7f879ec6ef94
8 changes: 2 additions & 6 deletions librdmacm/examples/cmatose.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,8 @@ static int run_server(void)
}

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
if (ret) {
printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret));
if (ret)
goto out;
}

ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr);
if (ret) {
Expand Down Expand Up @@ -594,10 +592,8 @@ static int run_client(void)
printf("cmatose: starting client\n");

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
if (ret) {
printf("cmatose: getaddrinfo error: %s\n", gai_strerror(ret));
if (ret)
return ret;
}

printf("cmatose: connecting\n");
for (i = 0; i < connections; i++) {
Expand Down
8 changes: 2 additions & 6 deletions librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,8 @@ static int run_server(void)
}

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
if (ret) {
printf("getrdmaaddr error: %s\n", gai_strerror(ret));
if (ret)
goto out;
}

ret = rdma_bind_addr(listen_id, rai->ai_src_addr);
if (ret) {
Expand All @@ -488,10 +486,8 @@ static int run_client(void)
int i, ret;

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
if (ret) {
if (ret)
printf("getaddrinfo error: %s\n", gai_strerror(ret));
return ret;
}

conn_param.responder_resources = 1;
conn_param.initiator_depth = 1;
Expand Down
11 changes: 8 additions & 3 deletions librdmacm/examples/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ int get_rdma_addr(const char *src, const char *dst, const char *port,
struct rdma_addrinfo rai_hints, *res;
int ret;

if (hints->ai_flags & RAI_PASSIVE)
return rdma_getaddrinfo(src, port, hints, rai);
if (hints->ai_flags & RAI_PASSIVE) {
ret = rdma_getaddrinfo(src, port, hints, rai);
goto out;
}

rai_hints = *hints;
if (src) {
rai_hints.ai_flags |= RAI_PASSIVE;
ret = rdma_getaddrinfo(src, NULL, &rai_hints, &res);
if (ret)
return ret;
goto out;

rai_hints.ai_src_addr = res->ai_src_addr;
rai_hints.ai_src_len = res->ai_src_len;
Expand All @@ -70,6 +72,9 @@ int get_rdma_addr(const char *src, const char *dst, const char *port,
if (src)
rdma_freeaddrinfo(res);

out:
if (ret)
printf("rdma_getaddrinfo error: %s\n", gai_strerror(ret));
return ret;
}

Expand Down
8 changes: 2 additions & 6 deletions librdmacm/examples/udaddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,8 @@ static int run_server(void)
}

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
if (ret) {
printf("udaddy: getrdmaaddr error: %s\n", gai_strerror(ret));
if (ret)
goto out;
}

ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr);
if (ret) {
Expand Down Expand Up @@ -571,10 +569,8 @@ static int run_client(void)
printf("udaddy: starting client\n");

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
if (ret) {
printf("udaddy: getaddrinfo error: %s\n", gai_strerror(ret));
if (ret)
return ret;
}

printf("udaddy: connecting\n");
for (i = 0; i < connections; i++) {
Expand Down