Skip to content

Commit

Permalink
Merge pull request #65 from mochi-hpc/dev-join-noswim-issue64
Browse files Browse the repository at this point in the history
add proper checks for join/refresh RPC return values
  • Loading branch information
shanedsnyder authored Jun 21, 2022
2 parents aeaad4c + 8204d8e commit 637875a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/ssg-rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int ssg_group_join_send(
}

/* if our initial buffer is too small, reallocate to the exact size & rejoin */
while (join_resp.view_buf_size > tmp_view_buf_size)
while (join_resp.ret == SSG_ERR_NOBUFS)
{
b = realloc(tmp_view_buf, join_resp.view_buf_size);
if(!b)
Expand Down Expand Up @@ -221,7 +221,8 @@ int ssg_group_join_send(
}

/* readjust view buf size if initial guess was too large */
if (join_resp.view_buf_size < tmp_view_buf_size)
if ((join_resp.view_buf_size < tmp_view_buf_size) &&
(join_resp.ret == SSG_SUCCESS))
{
b = realloc(tmp_view_buf, join_resp.view_buf_size);
if(!b)
Expand Down Expand Up @@ -604,7 +605,7 @@ int ssg_group_refresh_send(
}

/* if our initial buffer is too small, reallocate to the exact size & resend */
while (refresh_resp.view_buf_size > tmp_view_buf_size)
while (refresh_resp.ret == SSG_ERR_NOBUFS)
{
b = realloc(tmp_view_buf, refresh_resp.view_buf_size);
if(!b)
Expand Down Expand Up @@ -645,7 +646,8 @@ int ssg_group_refresh_send(
}

/* readjust view buf size if initial guess was too large */
if (refresh_resp.view_buf_size < tmp_view_buf_size)
if ((refresh_resp.view_buf_size < tmp_view_buf_size) &&
((refresh_resp.ret == SSG_SUCCESS)))
{
b = realloc(tmp_view_buf, refresh_resp.view_buf_size);
if(!b)
Expand Down
15 changes: 4 additions & 11 deletions tests/ssg-refresh-group.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
} \
} while(0)

#include <time.h>
double my_wtime() {
struct timeval time;
gettimeofday(&time, NULL);
return time.tv_sec + time.tv_usec/1000000.0;
}

DECLARE_MARGO_RPC_HANDLER(group_id_forward_recv_ult)

static void usage()
Expand Down Expand Up @@ -127,9 +120,9 @@ int main(int argc, char *argv[])

/* load group info from file */
num_addrs = SSG_ALL_MEMBERS;
load_time = my_wtime();
load_time = ABT_get_wtime();
sret = ssg_group_id_load(gid_file, &num_addrs, &g_id);
load_time = my_wtime() - load_time;
load_time = ABT_get_wtime() - load_time;
DIE_IF(sret != SSG_SUCCESS, "ssg_group_id_load (%s)", ssg_strerror(sret));
DIE_IF(num_addrs < 1, "ssg_group_id_load (%s)", ssg_strerror(sret));

Expand All @@ -149,10 +142,10 @@ int main(int argc, char *argv[])
DIE_IF(sret != SSG_ERR_MID_NOT_FOUND, "ssg_get_group_member_addr (%s)", ssg_strerror(sret));
DIE_IF(member_addr != HG_ADDR_NULL, "ssg_get_group_member_addr (%s)", ssg_strerror(sret));

refresh_time = my_wtime();
refresh_time = ABT_get_wtime();
/* refresh the SSG server group view */
sret = ssg_group_refresh(mid, g_id);
refresh_time = my_wtime() - refresh_time;
refresh_time = ABT_get_wtime() - refresh_time;
DIE_IF(sret != SSG_SUCCESS, "ssg_group_refresh (%s)", ssg_strerror(sret));

/* With a large number of clients, having everyone dump their group state
Expand Down

0 comments on commit 637875a

Please sign in to comment.