Skip to content

Commit

Permalink
Merge pull request ofiwg#3608 from j-xiong/master
Browse files Browse the repository at this point in the history
prov/psm2: Fix a bug in the connection clean-up protocol
  • Loading branch information
j-xiong authored Dec 9, 2017
2 parents 2be734a + 86bfa2d commit ce3ae45
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion prov/psm2/src/psmx2_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ static void *disconnect_func(void *args)
return NULL;
}

static int psmx2_peer_match(struct dlist_entry *item, const void *arg)
{
struct psmx2_epaddr_context *peer;

peer = container_of(item, struct psmx2_epaddr_context, entry);
return (peer->epaddr == arg);
}

int psmx2_am_trx_ctxt_handler_ext(psm2_am_token_t token, psm2_amarg_t *args,
int nargs, void *src, uint32_t len,
struct psmx2_trx_ctxt *trx_ctxt)
Expand All @@ -94,7 +102,11 @@ int psmx2_am_trx_ctxt_handler_ext(psm2_am_token_t token, psm2_amarg_t *args,
* the performance of this operation is not important.
*/
disconn = malloc(sizeof(*disconn));
if (args) {
if (disconn) {
psmx2_lock(&trx_ctxt->peer_lock, 2);
dlist_remove_first_match(&trx_ctxt->peer_list,
psmx2_peer_match, epaddr);
psmx2_unlock(&trx_ctxt->peer_lock, 2);
disconn->ep = trx_ctxt->psm2_ep;
disconn->epaddr = epaddr;
pthread_create(&disconnect_thread, NULL,
Expand Down Expand Up @@ -124,6 +136,7 @@ void psmx2_trx_ctxt_disconnect_peers(struct psmx2_trx_ctxt *trx_ctxt)
dlist_foreach_safe(&trx_ctxt->peer_list, item, tmp) {
dlist_remove(item);
peer = container_of(item, struct psmx2_epaddr_context, entry);
FI_INFO(&psmx2_prov, FI_LOG_CORE, "epaddr: %p\n", peer->epaddr);
psm2_am_request_short(peer->epaddr, PSMX2_AM_TRX_CTXT_HANDLER,
&arg, 1, NULL, 0, 0, NULL, NULL);
psm2_epaddr_setctxt(peer->epaddr, NULL);
Expand Down

0 comments on commit ce3ae45

Please sign in to comment.