@@ -1175,135 +1175,37 @@ static void _commitfn(int sd, short args, void *cbdata)
11751175 return rc ;
11761176}
11771177
1178- static void _resolve_peers (int sd , short args , void * cbdata )
1179- {
1180- pmix_cb_t * cb = (pmix_cb_t * )cbdata ;
1181- pmix_status_t rc ;
1182-
1183- cb -> status = pmix_preg .resolve_peers (cb -> key , cb -> pname .nspace ,
1184- & cb -> procs , & cb -> nprocs );
1185- /* post the data so the receiving thread can acquire it */
1186- PMIX_POST_OBJECT (cb );
1187- PMIX_WAKEUP_THREAD (& cb -> lock );
1188- }
1189-
11901178/* need to thread-shift this request */
11911179PMIX_EXPORT pmix_status_t PMIx_Resolve_peers (const char * nodename ,
11921180 const char * nspace ,
11931181 pmix_proc_t * * procs , size_t * nprocs )
11941182{
1195- pmix_cb_t * cb ;
1196- pmix_status_t rc ;
1197- pmix_proc_t proc ;
1198-
11991183 PMIX_ACQUIRE_THREAD (& pmix_global_lock );
12001184 if (pmix_globals .init_cntr <= 0 ) {
12011185 PMIX_RELEASE_THREAD (& pmix_global_lock );
12021186 return PMIX_ERR_INIT ;
12031187 }
12041188 PMIX_RELEASE_THREAD (& pmix_global_lock );
12051189
1190+ /* set default */
1191+ * procs = NULL ;
1192+ * nprocs = 0 ;
12061193
1207- cb = PMIX_NEW (pmix_cb_t );
1208- cb -> key = (char * )nodename ;
1209- cb -> pname .nspace = strdup (nspace );
1210-
1211- PMIX_THREADSHIFT (cb , _resolve_peers );
1212-
1213- /* wait for the result */
1214- PMIX_WAIT_THREAD (& cb -> lock );
1215-
1216- /* if the nspace wasn't found, then we need to
1217- * ask the server for that info */
1218- if (PMIX_ERR_INVALID_NAMESPACE == cb -> status ) {
1219- (void )strncpy (proc .nspace , nspace , PMIX_MAX_NSLEN );
1220- proc .rank = PMIX_RANK_WILDCARD ;
1221- /* any key will suffice as it will bring down
1222- * the entire data blob */
1223- rc = PMIx_Get (& proc , PMIX_UNIV_SIZE , NULL , 0 , NULL );
1224- if (PMIX_SUCCESS != rc ) {
1225- PMIX_RELEASE (cb );
1226- return rc ;
1227- }
1228- /* retry the fetch */
1229- cb -> lock .active = true;
1230- PMIX_THREADSHIFT (cb , _resolve_peers );
1231- PMIX_WAIT_THREAD (& cb -> lock );
1232- }
1233- * procs = cb -> procs ;
1234- * nprocs = cb -> nprocs ;
1235-
1236- rc = cb -> status ;
1237- PMIX_RELEASE (cb );
1238- return rc ;
1239- }
1240-
1241- static void _resolve_nodes (int fd , short args , void * cbdata )
1242- {
1243- pmix_cb_t * cb = (pmix_cb_t * )cbdata ;
1244- char * regex , * * names ;
1245-
1246- /* get a regular expression describing the PMIX_NODE_MAP */
1247- cb -> status = pmix_preg .resolve_nodes (cb -> pname .nspace , & regex );
1248- if (PMIX_SUCCESS == cb -> status ) {
1249- /* parse it into an argv array of names */
1250- cb -> status = pmix_preg .parse_nodes (regex , & names );
1251- if (PMIX_SUCCESS == cb -> status ) {
1252- /* assemble it into a comma-delimited list */
1253- cb -> key = pmix_argv_join (names , ',' );
1254- pmix_argv_free (names );
1255- } else {
1256- free (regex );
1257- }
1258- }
1259- /* post the data so the receiving thread can acquire it */
1260- PMIX_POST_OBJECT (cb );
1261- PMIX_WAKEUP_THREAD (& cb -> lock );
1194+ return pmix_preg .resolve_peers (nodename , nspace , procs , nprocs );
12621195}
12631196
12641197/* need to thread-shift this request */
12651198PMIX_EXPORT pmix_status_t PMIx_Resolve_nodes (const char * nspace , char * * nodelist )
12661199{
1267- pmix_cb_t * cb ;
1268- pmix_status_t rc ;
1269- pmix_proc_t proc ;
1270-
12711200 PMIX_ACQUIRE_THREAD (& pmix_global_lock );
12721201 if (pmix_globals .init_cntr <= 0 ) {
12731202 PMIX_RELEASE_THREAD (& pmix_global_lock );
12741203 return PMIX_ERR_INIT ;
12751204 }
12761205 PMIX_RELEASE_THREAD (& pmix_global_lock );
12771206
1278- cb = PMIX_NEW (pmix_cb_t );
1279- cb -> pname .nspace = strdup (nspace );
1280-
1281- PMIX_THREADSHIFT (cb , _resolve_nodes );
1282-
1283- /* wait for the result */
1284- PMIX_WAIT_THREAD (& cb -> lock );
1285-
1286- /* if the nspace wasn't found, then we need to
1287- * ask the server for that info */
1288- if (PMIX_ERR_INVALID_NAMESPACE == cb -> status ) {
1289- (void )strncpy (proc .nspace , nspace , PMIX_MAX_NSLEN );
1290- proc .rank = PMIX_RANK_WILDCARD ;
1291- /* any key will suffice as it will bring down
1292- * the entire data blob */
1293- rc = PMIx_Get (& proc , PMIX_UNIV_SIZE , NULL , 0 , NULL );
1294- if (PMIX_SUCCESS != rc ) {
1295- PMIX_RELEASE (cb );
1296- return rc ;
1297- }
1298- /* retry the fetch */
1299- cb -> lock .active = true;
1300- PMIX_THREADSHIFT (cb , _resolve_nodes );
1301- PMIX_WAIT_THREAD (& cb -> lock );
1302- }
1303- /* the string we want is in the key field */
1304- * nodelist = cb -> key ;
1207+ /* set default */
1208+ * nodelist = NULL ;
13051209
1306- rc = cb -> status ;
1307- PMIX_RELEASE (cb );
1308- return rc ;
1210+ return pmix_preg .resolve_nodes (nspace , nodelist );
13091211}
0 commit comments