Ensure we read all the reported URI contact info when we fork an HNP for singleton support
This commit was SVN r15714.
Этот коммит содержится в:
родитель
a13123b5fc
Коммит
066ff38d42
@ -223,6 +223,8 @@ orte_sds_base_seed_set_name(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define ORTE_URI_MSG_LGTH 256
|
||||||
|
|
||||||
static int fork_hnp(void)
|
static int fork_hnp(void)
|
||||||
{
|
{
|
||||||
#if !defined(__WINDOWS__)
|
#if !defined(__WINDOWS__)
|
||||||
@ -233,7 +235,8 @@ static int fork_hnp(void)
|
|||||||
char *param;
|
char *param;
|
||||||
sigset_t sigs;
|
sigset_t sigs;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char orted_uri[256];
|
int buffer_length, num_chars_read, chunk;
|
||||||
|
char *orted_uri;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* A pipe is used to communicate between the parent and child to
|
/* A pipe is used to communicate between the parent and child to
|
||||||
@ -369,12 +372,26 @@ static int fork_hnp(void)
|
|||||||
close(p[1]); /* parent closes the write - orted will write its contact info to it*/
|
close(p[1]); /* parent closes the write - orted will write its contact info to it*/
|
||||||
close(death_pipe[0]); /* parent closes the death_pipe's read */
|
close(death_pipe[0]); /* parent closes the death_pipe's read */
|
||||||
|
|
||||||
while (1) {
|
/* setup the buffer to read the uri */
|
||||||
rc = read(p[0], orted_uri, 255);
|
buffer_length = ORTE_URI_MSG_LGTH;
|
||||||
|
chunk = ORTE_URI_MSG_LGTH-1;
|
||||||
|
num_chars_read = 0;
|
||||||
|
orted_uri = (char*)malloc(buffer_length);
|
||||||
|
|
||||||
if (rc <= 0) {
|
while (1) {
|
||||||
|
|
||||||
|
while (chunk == (rc = read(p[0], &orted_uri[num_chars_read], chunk))) {
|
||||||
|
/* we read an entire buffer - better get more */
|
||||||
|
num_chars_read += chunk;
|
||||||
|
buffer_length += ORTE_URI_MSG_LGTH;
|
||||||
|
orted_uri = realloc((void*)orted_uri, buffer_length);
|
||||||
|
}
|
||||||
|
num_chars_read += rc;
|
||||||
|
|
||||||
|
if (num_chars_read <= 0) {
|
||||||
/* we didn't get anything back - this is bad */
|
/* we didn't get anything back - this is bad */
|
||||||
ORTE_ERROR_LOG(ORTE_ERR_HNP_COULD_NOT_START);
|
ORTE_ERROR_LOG(ORTE_ERR_HNP_COULD_NOT_START);
|
||||||
|
free(orted_uri);
|
||||||
return ORTE_ERR_HNP_COULD_NOT_START;
|
return ORTE_ERR_HNP_COULD_NOT_START;
|
||||||
}
|
}
|
||||||
/* we got something back - let's hope it was the uri.
|
/* we got something back - let's hope it was the uri.
|
||||||
@ -383,6 +400,7 @@ static int fork_hnp(void)
|
|||||||
*/
|
*/
|
||||||
if (ORTE_SUCCESS != (rc = orte_rml.set_contact_info(orted_uri))) {
|
if (ORTE_SUCCESS != (rc = orte_rml.set_contact_info(orted_uri))) {
|
||||||
ORTE_ERROR_LOG(rc);
|
ORTE_ERROR_LOG(rc);
|
||||||
|
free(orted_uri);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/* okay, the HNP is now setup. We actually don't need to
|
/* okay, the HNP is now setup. We actually don't need to
|
||||||
@ -397,6 +415,7 @@ static int fork_hnp(void)
|
|||||||
/* indicate we are a singleton so orte_init knows what to do */
|
/* indicate we are a singleton so orte_init knows what to do */
|
||||||
orte_process_info.singleton = true;
|
orte_process_info.singleton = true;
|
||||||
/* all done - report success */
|
/* all done - report success */
|
||||||
|
free(orted_uri);
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user