Skip to content

Commit

Permalink
Merge pull request ofiwg#2175 from j-xiong/master
Browse files Browse the repository at this point in the history
prov/psm,psm2: complete the memory corruption fix for fi_trywait()
  • Loading branch information
j-xiong authored Jun 30, 2016
2 parents 136b7ba + 724bd2c commit 918df62
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions prov/psm/src/psmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ int psmx_domain_open(struct fid_fabric *fabric, struct fi_info *info,
struct fid_domain **domain, void *context);
int psmx_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
struct fid_wait **waitset);
int psmx_wait_trywait(struct fid_fabric *fabric, struct fid **fids,
int count);
int psmx_ep_open(struct fid_domain *domain, struct fi_info *info,
struct fid_ep **ep, void *context);
int psmx_stx_ctx(struct fid_domain *domain, struct fi_tx_attr *attr,
Expand Down
2 changes: 1 addition & 1 deletion prov/psm/src/psmx_fabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static struct fi_ops_fabric psmx_fabric_ops = {
.passive_ep = fi_no_passive_ep,
.eq_open = ofi_eq_create,
.wait_open = psmx_wait_open,
.trywait = ofi_trywait
.trywait = psmx_wait_trywait,
};

static struct fi_fabric_attr psmx_fabric_attr = {
Expand Down
33 changes: 33 additions & 0 deletions prov/psm/src/psmx_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,36 @@ int psmx_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
return 0;
}

int psmx_wait_trywait(struct fid_fabric *fabric, struct fid **fids, int count)
{
struct psmx_fid_cq *cq_priv;
struct util_eq *eq;
struct util_wait *wait;
int i, ret;

for (i = 0; i < count; i++) {
switch (fids[i]->fclass) {
case FI_CLASS_CQ:
cq_priv = container_of(fids[i], struct psmx_fid_cq, cq);
wait = cq_priv->wait;
break;
case FI_CLASS_EQ:
eq = container_of(fids[i], struct util_eq, eq_fid.fid);
wait = eq->wait;
break;
case FI_CLASS_CNTR:
return -FI_ENOSYS;
case FI_CLASS_WAIT:
wait = container_of(fids[i], struct util_wait, wait_fid.fid);
break;
default:
return -FI_EINVAL;
}

ret = wait->try(wait);
if (ret)
return ret;
}
return 0;
}

3 changes: 2 additions & 1 deletion prov/psm2/src/psmx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ int psmx2_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
struct fid_cntr **cntr, void *context);
int psmx2_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
struct fid_wait **waitset);
int psmx2_wait_trywait(struct fid_fabric *fabric, struct fid **fids, int count);
int psmx2_wait_trywait(struct fid_fabric *fabric, struct fid **fids,
int count);

static inline void psmx2_fabric_acquire(struct psmx2_fid_fabric *fabric)
{
Expand Down
2 changes: 1 addition & 1 deletion prov/psm2/src/psmx2_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int psmx2_wait_trywait(struct fid_fabric *fabric, struct fid **fids, int count)
wait = cq_priv->wait;
break;
case FI_CLASS_EQ:
eq = container_of(fids[i], struct util_eq, eq_fid.fid)
eq = container_of(fids[i], struct util_eq, eq_fid.fid);
wait = eq->wait;
break;
case FI_CLASS_CNTR:
Expand Down

0 comments on commit 918df62

Please sign in to comment.