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
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/cmtime: Pair get_rdma_addr() with rdma_freeaddrinfo()
Move the get_rdma_addr() calls, which allocate rdma_addrinfo, into
main(), so that it can pair with the rdma_freeaddrinfo() call.  This
restructure makes the initialization and cleanup code easier to
follow.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
Sean Hefty committed Apr 9, 2024
commit 96476b93a724dd1ea7fbc99324147537b284192e
24 changes: 12 additions & 12 deletions librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@ static int run_server(void)
return ret;
}

ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
if (ret)
goto out;

ret = rdma_bind_addr(listen_id, rai->ai_src_addr);
if (ret) {
perror("bind address failed");
Expand All @@ -485,10 +481,6 @@ static int run_client(void)
pthread_t event_thread;
int i, ret;

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

conn_param.responder_resources = 1;
conn_param.initiator_depth = 1;
conn_param.retry_count = retries;
Expand Down Expand Up @@ -651,16 +643,23 @@ int main(int argc, char **argv)
init_qp_attr.cap.max_recv_sge = 1;
init_qp_attr.qp_type = IBV_QPT_RC;

if (!dst_addr)
hints.ai_flags |= RAI_PASSIVE;
ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
if (ret)
goto out;

channel = create_first_event_channel();
if (!channel) {
exit(1);
ret = -ENOMEM;
goto freeinfo;
}

if (dst_addr) {
nodes = calloc(sizeof *nodes, connections);
if (!nodes) {
ret = -ENOMEM;
goto destroy;
goto destchan;
}

ret = create_ids();
Expand All @@ -673,12 +672,13 @@ int main(int argc, char **argv)
freenodes:
free(nodes);
} else {
hints.ai_flags |= RAI_PASSIVE;
ret = run_server();
}

destroy:
destchan:
rdma_destroy_event_channel(channel);
freeinfo:
rdma_freeaddrinfo(rai);
out:
return ret;
}