Skip to content

Commit 83399ad

Browse files
committed
singleton: "safe" read/write to the pipe between (spawn'ed) orted and singleton
1 parent e7ae697 commit 83399ad

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

orte/mca/ess/singleton/ess_singleton_module.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ static int fork_hnp(void)
572572
memset(orted_uri, 0, buffer_length);
573573

574574
while (chunk == (rc = read(p[0], &orted_uri[num_chars_read], chunk))) {
575+
if (rc < 0 && (EAGAIN == errno || EINTR == errno)) {
576+
continue;
577+
} else {
578+
num_chars_read = 0;
579+
break;
580+
}
575581
/* we read an entire buffer - better get more */
576582
num_chars_read += chunk;
577583
orted_uri = realloc((void*)orted_uri, buffer_length+ORTE_URI_MSG_LGTH);

orte/orted/orted_main.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "opal/util/os_path.h"
6161
#include "opal/util/printf.h"
6262
#include "opal/util/argv.h"
63+
#include "opal/util/fd.h"
6364
#include "opal/runtime/opal.h"
6465
#include "opal/mca/base/mca_base_var.h"
6566
#include "opal/util/daemon_init.h"
@@ -598,8 +599,8 @@ int orte_daemon(int argc, char *argv[])
598599
}
599600
/* use setup fork to create the envars needed by the singleton */
600601
if (OPAL_SUCCESS != (ret = opal_pmix.server_setup_fork(&proc->name, &singenv))) {
601-
ORTE_ERROR_LOG(ret);
602-
goto DONE;
602+
ORTE_ERROR_LOG(ret);
603+
goto DONE;
603604
}
604605

605606
/* append the transport key to the envars needed by the singleton */
@@ -620,7 +621,10 @@ int orte_daemon(int argc, char *argv[])
620621
free(nptr);
621622

622623
/* pass that info to the singleton */
623-
write(orted_globals.uri_pipe, tmp, strlen(tmp)+1); /* need to add 1 to get the NULL */
624+
if (OPAL_SUCCESS != (ret = opal_fd_write(orted_globals.uri_pipe, strlen(tmp)+1, tmp))) { ; /* need to add 1 to get the NULL */
625+
ORTE_ERROR_LOG(ret);
626+
goto DONE;
627+
}
624628

625629
/* cleanup */
626630
free(tmp);

0 commit comments

Comments
 (0)