@@ -525,6 +525,9 @@ static void _toolconn(int sd, short args, void *cbdata)
525
525
pmix_data_buffer_t * buf ;
526
526
prte_plm_cmd_flag_t command = PRTE_PLM_ALLOC_JOBID_CMD ;
527
527
pmix_status_t xrc ;
528
+ bool primary = false;
529
+ bool nspace_given = false;
530
+ bool rank_given = false;
528
531
PRTE_HIDE_UNUSED_PARAMS (sd , args );
529
532
530
533
PMIX_ACQUIRE_OBJECT (cd );
@@ -560,8 +563,10 @@ static void _toolconn(int sd, short args, void *cbdata)
560
563
}
561
564
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_NSPACE )) {
562
565
PMIX_LOAD_NSPACE (cd -> target .nspace , cd -> info [n ].value .data .string );
566
+ nspace_given = true;
563
567
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_RANK )) {
564
568
cd -> target .rank = cd -> info [n ].value .data .rank ;
569
+ rank_given = true;
565
570
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_HOSTNAME )) {
566
571
cd -> operation = strdup (cd -> info [n ].value .data .string );
567
572
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_CMD_LINE )) {
@@ -570,6 +575,8 @@ static void _toolconn(int sd, short args, void *cbdata)
570
575
cd -> launcher = PMIX_INFO_TRUE (& cd -> info [n ]);
571
576
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_SERVER_SCHEDULER )) {
572
577
cd -> scheduler = PMIX_INFO_TRUE (& cd -> info [n ]);
578
+ } else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_PRIMARY_SERVER )) {
579
+ primary = PMIX_INFO_TRUE (& cd -> info [n ]);
573
580
} else if (PMIX_CHECK_KEY (& cd -> info [n ], PMIX_PROC_PID )) {
574
581
PMIX_VALUE_GET_NUMBER (xrc , & cd -> info [n ].value , cd -> pid , pid_t );
575
582
if (PMIX_SUCCESS != xrc ) {
@@ -599,11 +606,25 @@ static void _toolconn(int sd, short args, void *cbdata)
599
606
} else {
600
607
/* mark that the scheduler has attached to us */
601
608
prte_pmix_server_globals .scheduler_connected = true;
609
+ // the scheduler always self-assigns its ID
610
+ if (!nspace_given || !rank_given ) {
611
+ cd -> toolcbfunc (PMIX_ERR_NOT_SUPPORTED , NULL , cd -> cbdata );
612
+ PMIX_RELEASE (cd );
613
+ return ;
614
+ }
602
615
PMIX_LOAD_PROCID (& prte_pmix_server_globals .scheduler ,
603
616
cd -> target .nspace , cd -> target .rank );
604
- /* we cannot immediately set the scheduler to be our
605
- * PMIx server as the PMIx library hasn't finished
606
- * recording it */
617
+ rc = PMIX_SUCCESS ;
618
+
619
+ if (!primary ) {
620
+ /* we cannot immediately set the scheduler to be our
621
+ * PMIx server as the PMIx library hasn't finished
622
+ * recording it */
623
+ goto complete ;
624
+ }
625
+ // it has been recorded in the library, so record it here
626
+ prte_pmix_server_globals .scheduler_set_as_server = true;
627
+ goto complete ;
607
628
}
608
629
}
609
630
@@ -652,6 +673,8 @@ static void _toolconn(int sd, short args, void *cbdata)
652
673
if (PMIX_SUCCESS != rc ) {
653
674
rc = prte_pmix_convert_rc (rc );
654
675
}
676
+
677
+ complete :
655
678
if (NULL != cd -> toolcbfunc ) {
656
679
cd -> toolcbfunc (rc , & cd -> target , cd -> cbdata );
657
680
}
0 commit comments