Skip to content

Commit 59d6537

Browse files
author
rhc54
authored
Merge pull request #1918 from rhc54/topic/sdir
Establish a way for ORTE to tell PMIx the base tmpdir to use, and upd…
2 parents 160d9a7 + 16fccd4 commit 59d6537

File tree

5 files changed

+79
-33
lines changed

5 files changed

+79
-33
lines changed

opal/mca/pmix/pmix2x/pmix/include/pmix/pmix_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ BEGIN_C_DECLS
106106
#define PMIX_SERVER_TOOL_SUPPORT "pmix.srvr.tool" // (bool) The host RM wants to declare itself as willing to
107107
// accept tool connection requests
108108
#define PMIX_SERVER_PIDINFO "pmix.srvr.pidinfo" // (uint32_t) pid of the target server
109+
#define PMIX_SERVER_TMPDIR "pmix.srvr.tmpdir" // (char*) temp directory where PMIx server will place
110+
// client rendezvous points
111+
#define PMIX_SYSTEM_TMPDIR "pmix.sys.tmpdir" // (char*) temp directory for this system, where PMIx
112+
// server will place tool rendezvous points
109113

110114
/* identification attributes */
111115
#define PMIX_USERID "pmix.euid" // (uint32_t) effective user id

opal/mca/pmix/pmix2x/pmix/src/server/pmix_server.c

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ pmix_server_globals_t pmix_server_globals = {{{0}}};
6767
// local variables
6868
static char *security_mode = NULL;
6969
static pid_t mypid;
70+
static char *mytmpdir = NULL;
71+
static char *systmpdir = NULL;
7072

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

183185
/* find the temp dir */
184-
if (NULL == (tdir = getenv("PMIX_SERVER_TMPDIR"))) {
186+
if (NULL != mytmpdir) {
187+
tdir = mytmpdir;
188+
} else if (NULL == (tdir = getenv("PMIX_SERVER_TMPDIR"))) {
185189
if (NULL == (tdir = getenv("TMPDIR"))) {
186190
if (NULL == (tdir = getenv("TEMP"))) {
187191
if (NULL == (tdir = getenv("TMP"))) {
@@ -233,6 +237,7 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module,
233237
char *pmix_pid, *tdir;
234238
char **protected = NULL;
235239
bool protect;
240+
bool tool_support = false;
236241

237242
++pmix_globals.init_cntr;
238243
if (1 < pmix_globals.init_cntr) {
@@ -289,40 +294,51 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module,
289294
lt->mode = info[n].value.data.uint32;
290295
}
291296
} else if (0 == strcmp(info[n].key, PMIX_SERVER_TOOL_SUPPORT)) {
292-
pmix_listener_t *tl = PMIX_NEW(pmix_listener_t);
293-
tl -> address.sun_family = AF_UNIX;
294-
tl->protocol = PMIX_PROTOCOL_TOOL;
295-
/* Get up to 30 chars of hostname.*/
296-
gethostname(myhostname, myhostnamelen);
297-
/* ensure it is NULL terminated */
298-
myhostname[myhostnamelen-1] = '\0';
299-
/* need to put this in the global tmpdir as opposed to
300-
* where the server tmpdir might be */
301-
if (NULL == (tdir = getenv("TMPDIR"))) {
302-
if (NULL == (tdir = getenv("TEMP"))) {
303-
if (NULL == (tdir = getenv("TMP"))) {
304-
tdir = "/tmp";
305-
}
306-
}
307-
}
308-
if (0 > asprintf(&pmix_pid, "%s/pmix.%s.tool.%d", tdir, myhostname, mypid)) {
309-
return PMIX_ERR_NOMEM;
310-
}
311-
if ((strlen(pmix_pid) + 1) > sizeof(tl->address.sun_path)-1) {
312-
free(pmix_pid);
313-
return PMIX_ERR_INVALID_LENGTH;
297+
/* defer processing to ensure we pickup any tmpdir
298+
* directives before setting location */
299+
tool_support = true;
300+
} else if (0 == strcmp(info[n].key, PMIX_SERVER_TMPDIR)) {
301+
mytmpdir = strdup(info[n].value.data.string);
302+
} else if (0 == strcmp(info[n].key, PMIX_SYSTEM_TMPDIR)) {
303+
systmpdir = strdup(info[n].value.data.string);
304+
}
305+
}
306+
}
307+
if (tool_support) {
308+
pmix_listener_t *tl = PMIX_NEW(pmix_listener_t);
309+
tl -> address.sun_family = AF_UNIX;
310+
tl->protocol = PMIX_PROTOCOL_TOOL;
311+
/* Get up to 30 chars of hostname.*/
312+
gethostname(myhostname, myhostnamelen);
313+
/* ensure it is NULL terminated */
314+
myhostname[myhostnamelen-1] = '\0';
315+
/* need to put this in the global tmpdir as opposed to
316+
* where the server tmpdir might be */
317+
if (NULL != systmpdir) {
318+
tdir = systmpdir;
319+
} else if (NULL == (tdir = getenv("TMPDIR"))) {
320+
if (NULL == (tdir = getenv("TEMP"))) {
321+
if (NULL == (tdir = getenv("TMP"))) {
322+
tdir = "/tmp";
314323
}
315-
snprintf(tl->address.sun_path, sizeof(tl->address.sun_path) - 1, "%s", pmix_pid);
316-
free(pmix_pid);
317-
/* we don't provide a URI for this listener as we don't pass
318-
* the TOOL connection URI to a child process */
319-
pmix_server_globals.tool_connections_allowed = true;
320-
pmix_list_append(&pmix_server_globals.listeners, &tl->super);
321-
/* push this onto our protected list of keys not
322-
* to be passed to the clients */
323-
pmix_argv_append_nosize(&protected, PMIX_SERVER_TOOL_SUPPORT);
324324
}
325325
}
326+
if (0 > asprintf(&pmix_pid, "%s/pmix.%s.tool.%d", tdir, myhostname, mypid)) {
327+
return PMIX_ERR_NOMEM;
328+
}
329+
if ((strlen(pmix_pid) + 1) > sizeof(tl->address.sun_path)-1) {
330+
free(pmix_pid);
331+
return PMIX_ERR_INVALID_LENGTH;
332+
}
333+
snprintf(tl->address.sun_path, sizeof(tl->address.sun_path) - 1, "%s", pmix_pid);
334+
free(pmix_pid);
335+
/* we don't provide a URI for this listener as we don't pass
336+
* the TOOL connection URI to a child process */
337+
pmix_server_globals.tool_connections_allowed = true;
338+
pmix_list_append(&pmix_server_globals.listeners, &tl->super);
339+
/* push this onto our protected list of keys not
340+
* to be passed to the clients */
341+
pmix_argv_append_nosize(&protected, PMIX_SERVER_TOOL_SUPPORT);
326342
}
327343

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

427+
if (NULL != mytmpdir) {
428+
free(mytmpdir);
429+
}
430+
431+
if (NULL != systmpdir) {
432+
free(systmpdir);
433+
}
434+
411435
pmix_bfrop_close();
412436
pmix_sec_finalize();
413437
pmix_globals_finalize();

opal/mca/pmix/pmix_types.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
2+
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
33
* $COPYRIGHT$
44
*
55
* Additional copyrights may follow
@@ -44,6 +44,10 @@ BEGIN_C_DECLS
4444
#define OPAL_PMIX_SERVER_TOOL_SUPPORT "pmix.srvr.tool" // (bool) The host RM wants to declare itself as willing to
4545
// accept tool connection requests
4646
#define OPAL_PMIX_SERVER_PIDINFO "pmix.srvr.pidinfo" // (uint32_t) pid of the target server
47+
#define OPAL_PMIX_SERVER_TMPDIR "pmix.srvr.tmpdir" // (char*) temp directory where PMIx server will place
48+
// client rendezvous points
49+
#define OPAL_PMIX_SYSTEM_TMPDIR "pmix.sys.tmpdir" // (char*) temp directory where PMIx server will place
50+
// tool rendezvous points
4751

4852

4953
/* identification attributes */

orte/orted/pmix/pmix_server.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "orte/mca/rml/rml.h"
6565
#include "orte/mca/rml/base/rml_contact.h"
6666
#include "orte/util/name_fns.h"
67+
#include "orte/util/proc_info.h"
6768
#include "orte/util/session_dir.h"
6869
#include "orte/util/show_help.h"
6970
#include "orte/runtime/orte_globals.h"
@@ -249,11 +250,24 @@ int pmix_server_init(void)
249250
kv->type = OPAL_STRING;
250251
opal_list_append(&info, &kv->super);
251252
}
253+
/* tell the server to allow tool connections */
252254
kv = OBJ_NEW(opal_value_t);
253255
kv->key = strdup(OPAL_PMIX_SERVER_TOOL_SUPPORT);
254256
kv->type = OPAL_BOOL;
255257
kv->data.flag = true;
256258
opal_list_append(&info, &kv->super);
259+
/* tell the server our temp directory */
260+
kv = OBJ_NEW(opal_value_t);
261+
kv->key = strdup(OPAL_PMIX_SERVER_TMPDIR);
262+
kv->type = OPAL_STRING;
263+
kv->data.string = strdup(orte_process_info.tmpdir_base);
264+
opal_list_append(&info, &kv->super);
265+
/* use the same for the system temp directory */
266+
kv = OBJ_NEW(opal_value_t);
267+
kv->key = strdup(OPAL_PMIX_SYSTEM_TMPDIR);
268+
kv->type = OPAL_STRING;
269+
kv->data.string = strdup(orte_process_info.tmpdir_base);
270+
opal_list_append(&info, &kv->super);
257271

258272
/* setup the local server */
259273
if (ORTE_SUCCESS != (rc = opal_pmix.server_init(&pmix_server, &info))) {

orte/orted/pmix/pmix_server_register_fns.c

100755100644
File mode changed.

0 commit comments

Comments
 (0)