Skip to content

Commit

Permalink
fabtests: Refactor ft_sock_sync to take in a socket
Browse files Browse the repository at this point in the history
Make the socket to synchronize on an argument so that any
socket can be specified for synchronization instead of only
sock.

Signed-off-by: Zach Dworkin <zachary.dworkin@intel.com>
  • Loading branch information
zachdworkin committed Jun 20, 2024
1 parent e82c19b commit 4c90c24
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions fabtests/common/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -3916,31 +3916,31 @@ int ft_sock_recv(int fd, void *msg, size_t len)
return err ? err: 0;
}

int ft_sock_sync(int value)
int ft_sock_sync(int fd, int value)
{
int result = -FI_EOTHER;
int ret;

if (listen_sock < 0) {
ret = ft_sock_send(sock, &value, sizeof value);
ret = ft_sock_send(fd, &value, sizeof value);
if (ret) {
FT_PRINTERR("ft_sock_send", ret);
return ret;
}

ret = ft_sock_recv(sock, &result, sizeof result);
ret = ft_sock_recv(fd, &result, sizeof result);
if (ret) {
FT_PRINTERR("ft_sock_recv", ret);
return ret;
}
} else {
ret = ft_sock_recv(sock, &result, sizeof result);
ret = ft_sock_recv(fd, &result, sizeof result);
if (ret) {
FT_PRINTERR("ft_sock_recv", ret);
return ret;
}

ret = ft_sock_send(sock, &value, sizeof value);
ret = ft_sock_send(fd, &value, sizeof value);
if (ret) {
FT_PRINTERR("ft_sock_send", ret);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion fabtests/functional/cm_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static int run(void)
if (ret)
goto err1;

ret = ft_sock_sync(0);
ret = ft_sock_sync(sock, 0);
if (ret)
goto err1;
}
Expand Down
2 changes: 1 addition & 1 deletion fabtests/include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int ft_sock_connect(char *node, char *service);
int ft_sock_accept();
int ft_sock_send(int fd, void *msg, size_t len);
int ft_sock_recv(int fd, void *msg, size_t len);
int ft_sock_sync(int value);
int ft_sock_sync(int fd, int value);
void ft_sock_shutdown(int fd);
extern int (*ft_mr_alloc_func)(void);
extern uint64_t ft_tag;
Expand Down
6 changes: 3 additions & 3 deletions fabtests/ubertest/test_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static int ft_sync_test(int value)
if (ret)
return ret;

return ft_sock_sync(value);
return ft_sock_sync(sock, value);
}

static int ft_sync_manual()
Expand Down Expand Up @@ -444,7 +444,7 @@ static int ft_sync_progress(int value)
{
if (test_info.progress == FI_PROGRESS_MANUAL)
return ft_sync_manual();
return ft_sock_sync(value);
return ft_sock_sync(sock, value);
}

static int ft_sync_msg_needed(void)
Expand Down Expand Up @@ -1134,7 +1134,7 @@ int ft_init_test()
{
int ret;

ft_sock_sync(0);
ft_sock_sync(sock, 0);

ret = ft_enable_comm();
if (ret) {
Expand Down
4 changes: 2 additions & 2 deletions fabtests/ubertest/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static const int integ_alphabet_length = (sizeof(integ_alphabet)/sizeof(*integ_a
int ft_sync_fill_bufs(size_t size)
{
int ret;
ft_sock_sync(0);
ft_sock_sync(sock, 0);

if (test_info.caps & FI_ATOMIC) {
SWITCH_TYPES(ft_atom_ctrl.datatype, FT_FILL, ft_tx_ctrl.buf,
Expand All @@ -126,7 +126,7 @@ int ft_sync_fill_bufs(size_t size)
return ret;
}

ft_sock_sync(0);
ft_sock_sync(sock, 0);

return 0;
}
Expand Down

0 comments on commit 4c90c24

Please sign in to comment.