Skip to content

Commit

Permalink
librdmacm/examples: Rename create_first_event_channel, drop first
Browse files Browse the repository at this point in the history
This function just creates an event channel and prints a couple
of error messages on failure.  It has no concept of being the
'first' event channel, except by the caller's use.

Replace direct calls to rdma_create_event_channel() in the
example code with this call to make use of the existing error
messages.

Signed-off-by: Sean Hefty <shefty@nvidia.com>
  • Loading branch information
shefty committed Apr 9, 2024
1 parent 96476b9 commit f78349c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
8 changes: 3 additions & 5 deletions librdmacm/examples/cmatose.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,9 @@ static int migrate_channel(struct rdma_cm_id *listen_id)

printf("migrating to new event channel\n");

channel = rdma_create_event_channel();
if (!channel) {
perror("cmatose: failed to create event channel");
channel = create_event_channel();
if (!channel)
return -1;
}

ret = 0;
if (listen_id)
Expand Down Expand Up @@ -715,7 +713,7 @@ int main(int argc, char **argv)

test.connects_left = connections;

test.channel = create_first_event_channel();
test.channel = create_event_channel();
if (!test.channel) {
exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,9 @@ int main(int argc, char **argv)
if (ret)
goto out;

channel = create_first_event_channel();
channel = create_event_channel();
if (!channel) {
ret = -ENOMEM;
ret = -errno;
goto freeinfo;
}

Expand Down
2 changes: 1 addition & 1 deletion librdmacm/examples/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int do_poll(struct pollfd *fds, int timeout)
return ret == 1 ? (fds->revents & (POLLERR | POLLHUP)) : ret;
}

struct rdma_event_channel *create_first_event_channel(void)
struct rdma_event_channel *create_event_channel(void)
{
struct rdma_event_channel *channel;

Expand Down
3 changes: 2 additions & 1 deletion librdmacm/examples/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ int size_to_count(int size);
void format_buf(void *buf, int size);
int verify_buf(void *buf, int size);
int do_poll(struct pollfd *fds, int timeout);
struct rdma_event_channel *create_first_event_channel(void);

struct rdma_event_channel *create_event_channel(void);
2 changes: 1 addition & 1 deletion librdmacm/examples/mckey.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ int main(int argc, char **argv)
test.dst_addr = (struct sockaddr *) &test.dst_in;
test.connects_left = connections;

test.channel = create_first_event_channel();
test.channel = create_event_channel();
if (!test.channel) {
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion librdmacm/examples/rping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ int main(int argc, char *argv[])
goto out;
}

cb->cm_channel = create_first_event_channel();
cb->cm_channel = create_event_channel();
if (!cb->cm_channel) {
ret = errno;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion librdmacm/examples/udaddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ int main(int argc, char **argv)

test.connects_left = connections;

test.channel = create_first_event_channel();
test.channel = create_event_channel();
if (!test.channel) {
exit(1);
}
Expand Down

0 comments on commit f78349c

Please sign in to comment.