Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions opal/mca/pmix/pmix2x/pmix/include/pmix/pmix_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ BEGIN_C_DECLS
#define PMIX_SERVER_TOOL_SUPPORT "pmix.srvr.tool" // (bool) The host RM wants to declare itself as willing to
// accept tool connection requests
#define PMIX_SERVER_PIDINFO "pmix.srvr.pidinfo" // (uint32_t) pid of the target server
#define PMIX_SERVER_TMPDIR "pmix.srvr.tmpdir" // (char*) temp directory where PMIx server will place
// client rendezvous points
#define PMIX_SYSTEM_TMPDIR "pmix.sys.tmpdir" // (char*) temp directory for this system, where PMIx
// server will place tool rendezvous points

/* identification attributes */
#define PMIX_USERID "pmix.euid" // (uint32_t) effective user id
Expand Down
88 changes: 56 additions & 32 deletions opal/mca/pmix/pmix2x/pmix/src/server/pmix_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pmix_server_globals_t pmix_server_globals = {{{0}}};
// local variables
static char *security_mode = NULL;
static pid_t mypid;
static char *mytmpdir = NULL;
static char *systmpdir = NULL;

// local functions for connection support
static void server_message_handler(struct pmix_peer_t *pr, pmix_usock_hdr_t *hdr,
Expand Down Expand Up @@ -181,7 +183,9 @@ static pmix_status_t initialize_server_base(pmix_server_module_t *module)
security_mode = strdup(pmix_sec.name);

/* find the temp dir */
if (NULL == (tdir = getenv("PMIX_SERVER_TMPDIR"))) {
if (NULL != mytmpdir) {
tdir = mytmpdir;
} else if (NULL == (tdir = getenv("PMIX_SERVER_TMPDIR"))) {
if (NULL == (tdir = getenv("TMPDIR"))) {
if (NULL == (tdir = getenv("TEMP"))) {
if (NULL == (tdir = getenv("TMP"))) {
Expand Down Expand Up @@ -233,6 +237,7 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module,
char *pmix_pid, *tdir;
char **protected = NULL;
bool protect;
bool tool_support = false;

++pmix_globals.init_cntr;
if (1 < pmix_globals.init_cntr) {
Expand Down Expand Up @@ -289,40 +294,51 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module,
lt->mode = info[n].value.data.uint32;
}
} else if (0 == strcmp(info[n].key, PMIX_SERVER_TOOL_SUPPORT)) {
pmix_listener_t *tl = PMIX_NEW(pmix_listener_t);
tl -> address.sun_family = AF_UNIX;
tl->protocol = PMIX_PROTOCOL_TOOL;
/* Get up to 30 chars of hostname.*/
gethostname(myhostname, myhostnamelen);
/* ensure it is NULL terminated */
myhostname[myhostnamelen-1] = '\0';
/* need to put this in the global tmpdir as opposed to
* where the server tmpdir might be */
if (NULL == (tdir = getenv("TMPDIR"))) {
if (NULL == (tdir = getenv("TEMP"))) {
if (NULL == (tdir = getenv("TMP"))) {
tdir = "/tmp";
}
}
}
if (0 > asprintf(&pmix_pid, "%s/pmix.%s.tool.%d", tdir, myhostname, mypid)) {
return PMIX_ERR_NOMEM;
}
if ((strlen(pmix_pid) + 1) > sizeof(tl->address.sun_path)-1) {
free(pmix_pid);
return PMIX_ERR_INVALID_LENGTH;
/* defer processing to ensure we pickup any tmpdir
* directives before setting location */
tool_support = true;
} else if (0 == strcmp(info[n].key, PMIX_SERVER_TMPDIR)) {
mytmpdir = strdup(info[n].value.data.string);
} else if (0 == strcmp(info[n].key, PMIX_SYSTEM_TMPDIR)) {
systmpdir = strdup(info[n].value.data.string);
}
}
}
if (tool_support) {
pmix_listener_t *tl = PMIX_NEW(pmix_listener_t);
tl -> address.sun_family = AF_UNIX;
tl->protocol = PMIX_PROTOCOL_TOOL;
/* Get up to 30 chars of hostname.*/
gethostname(myhostname, myhostnamelen);
/* ensure it is NULL terminated */
myhostname[myhostnamelen-1] = '\0';
/* need to put this in the global tmpdir as opposed to
* where the server tmpdir might be */
if (NULL != systmpdir) {
tdir = systmpdir;
} else if (NULL == (tdir = getenv("TMPDIR"))) {
if (NULL == (tdir = getenv("TEMP"))) {
if (NULL == (tdir = getenv("TMP"))) {
tdir = "/tmp";
}
snprintf(tl->address.sun_path, sizeof(tl->address.sun_path) - 1, "%s", pmix_pid);
free(pmix_pid);
/* we don't provide a URI for this listener as we don't pass
* the TOOL connection URI to a child process */
pmix_server_globals.tool_connections_allowed = true;
pmix_list_append(&pmix_server_globals.listeners, &tl->super);
/* push this onto our protected list of keys not
* to be passed to the clients */
pmix_argv_append_nosize(&protected, PMIX_SERVER_TOOL_SUPPORT);
}
}
if (0 > asprintf(&pmix_pid, "%s/pmix.%s.tool.%d", tdir, myhostname, mypid)) {
return PMIX_ERR_NOMEM;
}
if ((strlen(pmix_pid) + 1) > sizeof(tl->address.sun_path)-1) {
free(pmix_pid);
return PMIX_ERR_INVALID_LENGTH;
}
snprintf(tl->address.sun_path, sizeof(tl->address.sun_path) - 1, "%s", pmix_pid);
free(pmix_pid);
/* we don't provide a URI for this listener as we don't pass
* the TOOL connection URI to a child process */
pmix_server_globals.tool_connections_allowed = true;
pmix_list_append(&pmix_server_globals.listeners, &tl->super);
/* push this onto our protected list of keys not
* to be passed to the clients */
pmix_argv_append_nosize(&protected, PMIX_SERVER_TOOL_SUPPORT);
}

/* setup the wildcard recv for inbound messages from clients */
Expand Down Expand Up @@ -408,6 +424,14 @@ static void cleanup_server_state(void)
free(security_mode);
}

if (NULL != mytmpdir) {
free(mytmpdir);
}

if (NULL != systmpdir) {
free(systmpdir);
}

pmix_bfrop_close();
pmix_sec_finalize();
pmix_globals_finalize();
Expand Down
6 changes: 5 additions & 1 deletion opal/mca/pmix/pmix_types.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -44,6 +44,10 @@ BEGIN_C_DECLS
#define OPAL_PMIX_SERVER_TOOL_SUPPORT "pmix.srvr.tool" // (bool) The host RM wants to declare itself as willing to
// accept tool connection requests
#define OPAL_PMIX_SERVER_PIDINFO "pmix.srvr.pidinfo" // (uint32_t) pid of the target server
#define OPAL_PMIX_SERVER_TMPDIR "pmix.srvr.tmpdir" // (char*) temp directory where PMIx server will place
// client rendezvous points
#define OPAL_PMIX_SYSTEM_TMPDIR "pmix.sys.tmpdir" // (char*) temp directory where PMIx server will place
// tool rendezvous points


/* identification attributes */
Expand Down
14 changes: 14 additions & 0 deletions orte/orted/pmix/pmix_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "orte/mca/rml/rml.h"
#include "orte/mca/rml/base/rml_contact.h"
#include "orte/util/name_fns.h"
#include "orte/util/proc_info.h"
#include "orte/util/session_dir.h"
#include "orte/util/show_help.h"
#include "orte/runtime/orte_globals.h"
Expand Down Expand Up @@ -249,11 +250,24 @@ int pmix_server_init(void)
kv->type = OPAL_STRING;
opal_list_append(&info, &kv->super);
}
/* tell the server to allow tool connections */
kv = OBJ_NEW(opal_value_t);
kv->key = strdup(OPAL_PMIX_SERVER_TOOL_SUPPORT);
kv->type = OPAL_BOOL;
kv->data.flag = true;
opal_list_append(&info, &kv->super);
/* tell the server our temp directory */
kv = OBJ_NEW(opal_value_t);
kv->key = strdup(OPAL_PMIX_SERVER_TMPDIR);
kv->type = OPAL_STRING;
kv->data.string = strdup(orte_process_info.tmpdir_base);
opal_list_append(&info, &kv->super);
/* use the same for the system temp directory */
kv = OBJ_NEW(opal_value_t);
kv->key = strdup(OPAL_PMIX_SYSTEM_TMPDIR);
kv->type = OPAL_STRING;
kv->data.string = strdup(orte_process_info.tmpdir_base);
opal_list_append(&info, &kv->super);

/* setup the local server */
if (ORTE_SUCCESS != (rc = opal_pmix.server_init(&pmix_server, &info))) {
Expand Down
Empty file modified orte/orted/pmix/pmix_server_register_fns.c
100755 → 100644
Empty file.