Skip to content

Commit 18a0219

Browse files
authored
Merge pull request #2885 from ggouaillardet/topic/v2.x/pmix112
v2.x: pmix: fix PMIx_server_register_nspace() usage
2 parents fdd1b24 + 1bf3237 commit 18a0219

File tree

8 files changed

+62
-24
lines changed

8 files changed

+62
-24
lines changed

opal/mca/pmix/external/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-2015 Intel, Inc. All rights reserved.
4-
* Copyright (c) 2014-2015 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 Mellanox Technologies, Inc.
77
* All rights reserved.
@@ -490,6 +490,7 @@ static void opcon(pmix_ext_opcaddy_t *p)
490490
p->ninfo = 0;
491491
p->apps = NULL;
492492
p->sz = 0;
493+
p->active = false;
493494
p->opcbfunc = NULL;
494495
p->mdxcbfunc = NULL;
495496
p->valcbfunc = NULL;

opal/mca/pmix/external/pmix_ext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
33
* Copyright (c) 2014-2015 Mellanox Technologies, Inc.
44
* All rights reserved.
5+
* Copyright (c) 2017 Research Organization for Information Science
6+
* and Technology (RIST). All rights reserved.
57
* $COPYRIGHT$
68
*
79
* Additional copyrights may follow
@@ -61,6 +63,7 @@ typedef struct {
6163
size_t ninfo;
6264
pmix_app_t *apps;
6365
size_t sz;
66+
volatile bool active;
6467
opal_pmix_op_cbfunc_t opcbfunc;
6568
opal_pmix_modex_cbfunc_t mdxcbfunc;
6669
opal_pmix_value_cbfunc_t valcbfunc;

opal/mca/pmix/external/pmix_ext_server_south.c

Lines changed: 23 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-2015 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 Mellanox Technologies, Inc.
77
* All rights reserved.
@@ -54,6 +54,14 @@ static void release_cbfunc(void *cbdata)
5454
pmix_ext_opalcaddy_t *cd = (pmix_ext_opalcaddy_t*)cbdata;
5555
OBJ_RELEASE(cd);
5656
}
57+
58+
#define PMIX_WAIT_FOR_COMPLETION(a) \
59+
do { \
60+
while ((a)) { \
61+
usleep(10); \
62+
} \
63+
} while (0);
64+
5765
static void myerr(pmix_status_t status,
5866
pmix_proc_t procs[], size_t nprocs,
5967
pmix_info_t info[], size_t ninfo)
@@ -178,7 +186,11 @@ static void opcbfunc(pmix_status_t status, void *cbdata)
178186
if (NULL != op->opcbfunc) {
179187
op->opcbfunc(pmix_ext_convert_rc(status), op->cbdata);
180188
}
181-
OBJ_RELEASE(op);
189+
if (op->active) {
190+
op->active = false;
191+
} else {
192+
OBJ_RELEASE(op);
193+
}
182194
}
183195

184196
int pmix_ext_server_register_nspace(opal_jobid_t jobid,
@@ -192,7 +204,7 @@ int pmix_ext_server_register_nspace(opal_jobid_t jobid,
192204
size_t sz, szmap, m, n;
193205
char nspace[PMIX_MAX_NSLEN];
194206
pmix_status_t rc;
195-
pmix_ext_opcaddy_t *op;
207+
pmix_ext_opcaddy_t op;
196208
opal_list_t *pmapinfo;
197209
opal_pmix_ext_jobid_trkr_t *job;
198210

@@ -238,15 +250,15 @@ int pmix_ext_server_register_nspace(opal_jobid_t jobid,
238250
}
239251

240252
/* setup the caddy */
241-
op = OBJ_NEW(pmix_ext_opcaddy_t);
242-
op->info = pinfo;
243-
op->sz = sz;
244-
op->opcbfunc = cbfunc;
245-
op->cbdata = cbdata;
253+
OBJ_CONSTRUCT(&op, pmix_ext_opcaddy_t);
254+
op.info = pinfo;
255+
op.sz = sz;
256+
op.opcbfunc = cbfunc;
257+
op.cbdata = cbdata;
246258
rc = PMIx_server_register_nspace(nspace, nlocalprocs, pinfo, sz,
247-
opcbfunc, op);
248-
if (PMIX_SUCCESS != rc) {
249-
OBJ_RELEASE(op);
259+
opcbfunc, &op);
260+
if (PMIX_SUCCESS == rc) {
261+
PMIX_WAIT_FOR_COMPLETION(op.active);
250262
}
251263
return pmix_ext_convert_rc(rc);
252264
}

opal/mca/pmix/pmix112/pmix1.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/*
22
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2017 Research Organization for Information Science
4+
* and Technology (RIST). All rights reserved.
35
* $COPYRIGHT$
46
*
57
* Additional copyrights may follow
@@ -59,6 +61,7 @@ typedef struct {
5961
size_t ninfo;
6062
pmix_app_t *apps;
6163
size_t sz;
64+
volatile bool active;
6265
opal_pmix_op_cbfunc_t opcbfunc;
6366
opal_pmix_modex_cbfunc_t mdxcbfunc;
6467
opal_pmix_value_cbfunc_t valcbfunc;

opal/mca/pmix/pmix112/pmix1_server_south.c

Lines changed: 24 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-2015 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 Mellanox Technologies, Inc.
77
* All rights reserved.
@@ -54,6 +54,14 @@ static void release_cbfunc(void *cbdata)
5454
pmix1_opalcaddy_t *cd = (pmix1_opalcaddy_t*)cbdata;
5555
OBJ_RELEASE(cd);
5656
}
57+
58+
#define PMIX_WAIT_FOR_COMPLETION(a) \
59+
do { \
60+
while ((a)) { \
61+
usleep(10); \
62+
} \
63+
} while (0);
64+
5765
static void myerr(pmix_status_t status,
5866
pmix_proc_t procs[], size_t nprocs,
5967
pmix_info_t info[], size_t ninfo)
@@ -178,7 +186,11 @@ static void opcbfunc(pmix_status_t status, void *cbdata)
178186
if (NULL != op->opcbfunc) {
179187
op->opcbfunc(pmix1_convert_rc(status), op->cbdata);
180188
}
181-
OBJ_RELEASE(op);
189+
if (op->active) {
190+
op->active = false;
191+
} else {
192+
OBJ_RELEASE(op);
193+
}
182194
}
183195

184196
int pmix1_server_register_nspace(opal_jobid_t jobid,
@@ -192,7 +204,7 @@ int pmix1_server_register_nspace(opal_jobid_t jobid,
192204
size_t sz, szmap, m, n;
193205
char nspace[PMIX_MAX_NSLEN];
194206
pmix_status_t rc;
195-
pmix1_opcaddy_t *op;
207+
pmix1_opcaddy_t op;
196208
opal_list_t *pmapinfo;
197209
opal_pmix1_jobid_trkr_t *job;
198210

@@ -238,15 +250,16 @@ int pmix1_server_register_nspace(opal_jobid_t jobid,
238250
}
239251

240252
/* setup the caddy */
241-
op = OBJ_NEW(pmix1_opcaddy_t);
242-
op->info = pinfo;
243-
op->sz = sz;
244-
op->opcbfunc = cbfunc;
245-
op->cbdata = cbdata;
253+
OBJ_CONSTRUCT(&op, pmix1_opcaddy_t);
254+
op.info = pinfo;
255+
op.sz = sz;
256+
op.opcbfunc = cbfunc;
257+
op.cbdata = cbdata;
258+
op.active = true;
246259
rc = PMIx_server_register_nspace(nspace, nlocalprocs, pinfo, sz,
247-
opcbfunc, op);
248-
if (PMIX_SUCCESS != rc) {
249-
OBJ_RELEASE(op);
260+
opcbfunc, &op);
261+
if (PMIX_SUCCESS == rc) {
262+
PMIX_WAIT_FOR_COMPLETION(op.active);
250263
}
251264
return pmix1_convert_rc(rc);
252265
}

opal/mca/pmix/pmix112/pmix_pmix1.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-2015 Intel, Inc. All rights reserved.
4-
* Copyright (c) 2014-2015 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 Mellanox Technologies, Inc.
77
* All rights reserved.
@@ -490,6 +490,7 @@ static void opcon(pmix1_opcaddy_t *p)
490490
p->ninfo = 0;
491491
p->apps = NULL;
492492
p->sz = 0;
493+
p->active = false;
493494
p->opcbfunc = NULL;
494495
p->mdxcbfunc = NULL;
495496
p->valcbfunc = NULL;

orte/mca/ess/hnp/ess_hnp_component.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2017 Intel, Inc. All rights reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -26,6 +28,8 @@
2628
* entire components just to query their version and parameters.
2729
*/
2830

31+
#include "opal/util/argv.h"
32+
2933
#include "orte_config.h"
3034
#include "orte/constants.h"
3135

orte/runtime/orte_finalize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "opal/runtime/opal.h"
2929
#include "opal/util/output.h"
30+
#include "opal/util/argv.h"
3031

3132
#include "orte/mca/ess/ess.h"
3233
#include "orte/mca/ess/base/base.h"

0 commit comments

Comments
 (0)