3636#endif
3737
3838#include "src/include/pmix_globals.h"
39+ #include "src/include/pmix_dictionary.h"
40+ #include "src/include/pmix_types.h"
41+
3942#include "src/mca/base/pmix_base.h"
4043#include "src/mca/base/pmix_mca_base_var.h"
4144#include "src/mca/bfrops/base/base.h"
4952#include "src/mca/psec/base/base.h"
5053#include "src/mca/psquash/base/base.h"
5154#include "src/mca/ptl/base/base.h"
55+
56+ #include "src/util/pmix_error.h"
57+ #include "src/util/pmix_keyval_parse.h"
5258#include "src/util/pmix_name_fns.h"
5359#include "src/util/pmix_net.h"
5460#include "src/util/pmix_output.h"
5864#include "src/client/pmix_client_ops.h"
5965#include "src/common/pmix_attributes.h"
6066#include "src/event/pmix_event.h"
61- #include "src/include/pmix_dictionary.h"
62- #include "src/include/pmix_types.h"
63- #include "src/util/pmix_error.h"
64- #include "src/util/pmix_keyval_parse.h"
6567
6668#include "src/runtime/pmix_progress_threads.h"
6769#include "src/runtime/pmix_rte.h"
@@ -87,6 +89,7 @@ PMIX_EXPORT pmix_globals_t pmix_globals = {
8789 .realgid = 0 ,
8890 .gid = 0 ,
8991 .hostname = NULL ,
92+ .aliases = NULL ,
9093 .appnum = 0 ,
9194 .pid = 0 ,
9295 .nodeid = UINT32_MAX ,
@@ -226,7 +229,6 @@ int pmix_rte_init(uint32_t type, pmix_info_t info[], size_t ninfo, pmix_ptl_cbfu
226229 char hostname [PMIX_MAXHOSTNAMELEN ] = {0 };
227230 pmix_info_t * iptr ;
228231 size_t minfo ;
229- bool keepfqdn = false;
230232 pmix_iof_flags_t flags ;
231233
232234#if PMIX_NO_LIB_DESTRUCTOR
@@ -283,7 +285,7 @@ int pmix_rte_init(uint32_t type, pmix_info_t info[], size_t ninfo, pmix_ptl_cbfu
283285 } else if (PMIX_CHECK_KEY (& info [n ], PMIX_EXTERNAL_AUX_EVENT_BASE )) {
284286 pmix_globals .evauxbase = (pmix_event_base_t * )info [n ].value .data .ptr ;
285287 } else if (PMIX_CHECK_KEY (& info [n ], PMIX_HOSTNAME_KEEP_FQDN )) {
286- keepfqdn = PMIX_INFO_TRUE (& info [n ]);
288+ pmix_keep_fqdn_hostnames = PMIX_INFO_TRUE (& info [n ]);
287289 } else if (PMIX_CHECK_KEY (& info [n ], PMIX_BIND_PROGRESS_THREAD )) {
288290 if (NULL != pmix_progress_thread_cpus ) {
289291 free (pmix_progress_thread_cpus );
@@ -435,12 +437,9 @@ int pmix_rte_init(uint32_t type, pmix_info_t info[], size_t ninfo, pmix_ptl_cbfu
435437 /* if we weren't previously given a hostname, then
436438 * use the OS one */
437439 gethostname (hostname , PMIX_MAXHOSTNAMELEN - 1 );
438- /* strip the FQDN unless told to keep it */
439- if (!keepfqdn && !pmix_net_isaddr (hostname ) && NULL != (evar = strchr (hostname , '.' ))) {
440- * evar = '\0' ;
441- }
442440 pmix_globals .hostname = strdup (hostname );
443441 }
442+ pmix_set_aliases (& pmix_globals .aliases , pmix_globals .hostname );
444443 }
445444
446445 /* the choice of modules to use when communicating with a peer
@@ -582,3 +581,23 @@ int pmix_finalize_util(void)
582581 util_initialized = false;
583582 return PMIX_SUCCESS ;
584583}
584+
585+ void pmix_set_aliases (char * * * aliases , char * hostname )
586+ {
587+ char * ptr ;
588+
589+ if (!pmix_net_isaddr (hostname ) &&
590+ NULL != (ptr = strchr (hostname , '.' ))) {
591+ if (pmix_keep_fqdn_hostnames ) {
592+ /* retain the non-fqdn name as an alias */
593+ * ptr = '\0' ;
594+ PMIx_Argv_append_unique_nosize (aliases , hostname );
595+ * ptr = '.' ;
596+ } else {
597+ /* add the fqdn name as an alias */
598+ PMIx_Argv_append_unique_nosize (aliases , hostname );
599+ /* retain the non-fqdn name as the node's name */
600+ * ptr = '\0' ;
601+ }
602+ }
603+ }
0 commit comments