Skip to content

Commit dccb189

Browse files
committed
pmix/ext11: correctly use PMIx_server_register_nspace()
PMIx_server_register_nspace() is an asynchronous operation, so the pmix glue wait for it completes before returning. Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 6955e1e commit dccb189

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

opal/mca/pmix/ext11/pmix_ext.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
33
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
4-
* Copyright (c) 2014-2016 Research Organization for Information Science
4+
* Copyright (c) 2014-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2014-2015 Mellanox Technologies, Inc.
77
* All rights reserved.
@@ -527,6 +527,7 @@ static void opcon(pmix1_opcaddy_t *p)
527527
p->ninfo = 0;
528528
p->apps = NULL;
529529
p->sz = 0;
530+
p->active = false;
530531
p->opcbfunc = NULL;
531532
p->mdxcbfunc = NULL;
532533
p->valcbfunc = NULL;

opal/mca/pmix/ext11/pmix_ext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
33
* Copyright (c) 2014-2015 Mellanox Technologies, Inc.
44
* All rights reserved.
5-
* Copyright (c) 2016 Research Organization for Information Science
5+
* Copyright (c) 2016-2017 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
77
* $COPYRIGHT$
88
*
@@ -62,6 +62,7 @@ typedef struct {
6262
size_t ninfo;
6363
pmix_app_t *apps;
6464
size_t sz;
65+
volatile bool active;
6566
opal_pmix_op_cbfunc_t opcbfunc;
6667
opal_pmix_modex_cbfunc_t mdxcbfunc;
6768
opal_pmix_value_cbfunc_t valcbfunc;

opal/mca/pmix/ext11/pmix_ext_server_south.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
33
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
4-
* Copyright (c) 2014-2016 Research Organization for Information Science
4+
* Copyright (c) 2014-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
77
* Copyright (c) 2014 Mellanox Technologies, Inc.
@@ -193,7 +193,11 @@ static void opcbfunc(pmix_status_t status, void *cbdata)
193193
if (NULL != op->opcbfunc) {
194194
op->opcbfunc(pmix1_convert_rc(status), op->cbdata);
195195
}
196-
OBJ_RELEASE(op);
196+
if (op->active) {
197+
op->active = false;
198+
} else {
199+
OBJ_RELEASE(op);
200+
}
197201
}
198202

199203
int pmix1_server_register_nspace(opal_jobid_t jobid,
@@ -207,7 +211,7 @@ int pmix1_server_register_nspace(opal_jobid_t jobid,
207211
size_t sz, szmap, m, n;
208212
char nspace[PMIX_MAX_NSLEN];
209213
pmix_status_t rc;
210-
pmix1_opcaddy_t *op;
214+
pmix1_opcaddy_t op;
211215
opal_list_t *pmapinfo;
212216
opal_pmix1_jobid_trkr_t *job;
213217

@@ -253,15 +257,16 @@ int pmix1_server_register_nspace(opal_jobid_t jobid,
253257
}
254258

255259
/* setup the caddy */
256-
op = OBJ_NEW(pmix1_opcaddy_t);
257-
op->info = pinfo;
258-
op->sz = sz;
259-
op->opcbfunc = cbfunc;
260-
op->cbdata = cbdata;
260+
OBJ_CONSTRUCT(&op, pmix1_opcaddy_t);
261+
op.info = pinfo;
262+
op.sz = sz;
263+
op.opcbfunc = cbfunc;
264+
op.cbdata = cbdata;
265+
op.active = true;
261266
rc = PMIx_server_register_nspace(nspace, nlocalprocs, pinfo, sz,
262-
opcbfunc, op);
263-
if (PMIX_SUCCESS != rc) {
264-
OBJ_RELEASE(op);
267+
opcbfunc, &op);
268+
if (PMIX_SUCCESS == rc) {
269+
PMIX_WAIT_FOR_COMPLETION(op.active);
265270
}
266271
return pmix1_convert_rc(rc);
267272
}

0 commit comments

Comments
 (0)