Skip to content

Commit

Permalink
cm_data: Handled fi_shutdown event
Browse files Browse the repository at this point in the history
Signed-off-by: Shantonu Hossain <[email protected]>
  • Loading branch information
shantonu committed Jul 23, 2016
1 parent 5e6a6f6 commit ba4bee1
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions simple/cm_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ static size_t cm_data_size;
static struct fi_eq_cm_entry *entry;
static struct fi_eq_err_entry err_entry;

static int read_shutdown_event()
{
int ret;
uint32_t event;

memset(entry, 0, sizeof(*entry));
ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0);
if (ret < 0) {
FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "shutdown");
return ret;
}
if (event != FI_SHUTDOWN || entry->fid != &ep->fid) {
FT_ERR("Unexpected CM event %d fid %p (ep %p)", event,
entry->fid, ep);
ret = -FI_EOTHER;
return ret;
}
return 0;
}

static int server_setup(void)
{
size_t opt_size;
Expand Down Expand Up @@ -99,6 +119,7 @@ static int server_listen(size_t paramlen)
int ret;

expected = paramlen + sizeof(*entry);
memset(entry, 0, expected);

ret = fi_eq_sread(eq, &event, entry, expected, -1, 0);
if (ret != expected) {
Expand Down Expand Up @@ -176,7 +197,7 @@ static int server_accept(size_t paramlen)
}

/* Local FI_CONNECTED event does not have data associated. */
memset(entry, 0, sizeof(*entry) + paramlen);
memset(entry, 0, sizeof(*entry));
ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0);
if (ret != sizeof(*entry)) {
FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "accept");
Expand All @@ -191,6 +212,9 @@ static int server_accept(size_t paramlen)
}

fi_shutdown(ep, 0);
ret = read_shutdown_event();
if (ret)
goto err;

FT_CLOSE_FID(ep);
FT_CLOSE_FID(rxcq);
Expand Down Expand Up @@ -245,8 +269,8 @@ static int client_expect_reject(size_t paramlen)

ret = fi_eq_readerr(eq, &err_entry, 0);
if (ret != sizeof(err_entry)) {
FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_readerr", "listen");
return ret;
FT_EQ_ERR(eq, err_entry, NULL, 0);
return err_entry.err;
}

if (err_entry.err != FI_ECONNREFUSED)
Expand Down Expand Up @@ -288,6 +312,9 @@ static int client_expect_accept(size_t paramlen)
return ret;

fi_shutdown(ep, 0);
ret = read_shutdown_event();
if (ret)
return ret;

return 0;
}
Expand Down Expand Up @@ -338,7 +365,7 @@ static int run(void)
ret = server(i);

if (ret)
return ret;
goto err;
}

/* Despite server not being setup to handle this, the client should fail
Expand All @@ -356,7 +383,8 @@ static int run(void)
ret = FI_SUCCESS;
}
}

err:
free(entry);
return ret;
}

Expand Down

0 comments on commit ba4bee1

Please sign in to comment.