1
1

iof: optimize handling of stderr when iof_base_redirect_app_stderr_to_stdout is set

avoid creating a pipe for a task stderr when we know it will be redirected to stdout

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
Gilles Gouaillardet 2017-11-24 11:16:22 +09:00
родитель 84e96522f2
Коммит e88767866e
5 изменённых файлов: 33 добавлений и 15 удалений

Просмотреть файл

@ -113,9 +113,11 @@ orte_iof_base_setup_prefork(orte_iof_base_io_conf_t *opts)
return ORTE_ERR_SYS_LIMITS_PIPES;
}
}
if (pipe(opts->p_stderr) < 0) {
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
return ORTE_ERR_SYS_LIMITS_PIPES;
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
if (pipe(opts->p_stderr) < 0) {
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
return ORTE_ERR_SYS_LIMITS_PIPES;
}
}
if (pipe(opts->p_internal) < 0) {
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
@ -136,7 +138,9 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
close(opts->p_stdin[1]);
}
close(opts->p_stdout[0]);
close(opts->p_stderr[0]);
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
close(opts->p_stderr[0]);
}
close(opts->p_internal[0]);
if (opts->usepty) {
@ -197,8 +201,8 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
ret = dup2(opts->p_stderr[1], fileno(stderr));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
close(opts->p_stderr[1]);
}
close(opts->p_stderr[1]);
}
if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) {
@ -241,10 +245,12 @@ orte_iof_base_setup_parent(const orte_process_name_t* name,
return ret;
}
ret = orte_iof.push(name, ORTE_IOF_STDERR, opts->p_stderr[0]);
if(ORTE_SUCCESS != ret) {
ORTE_ERROR_LOG(ret);
return ret;
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
ret = orte_iof.push(name, ORTE_IOF_STDERR, opts->p_stderr[0]);
if(ORTE_SUCCESS != ret) {
ORTE_ERROR_LOG(ret);
return ret;
}
}
ret = orte_iof.push(name, ORTE_IOF_STDDIAG, opts->p_internal[0]);

Просмотреть файл

@ -201,7 +201,8 @@ static int hnp_push(const orte_process_name_t* dst_name, orte_iof_tag_t src_tag,
* because one of the readevents fires -prior- to all of them having
* been defined!
*/
if (NULL != proct->revstdout && NULL != proct->revstderr && NULL != proct->revstddiag) {
if (NULL != proct->revstdout && NULL != proct->revstddiag &&
(orte_iof_base.redirect_app_stderr_to_stdout || NULL != proct->revstderr)) {
if (proct->copy) {
/* see if there are any wildcard subscribers out there that
* apply to us */
@ -216,7 +217,9 @@ static int hnp_push(const orte_process_name_t* dst_name, orte_iof_tag_t src_tag,
}
}
ORTE_IOF_READ_ACTIVATE(proct->revstdout);
ORTE_IOF_READ_ACTIVATE(proct->revstderr);
if (!orte_iof_base.redirect_app_stderr_to_stdout) {
ORTE_IOF_READ_ACTIVATE(proct->revstderr);
}
ORTE_IOF_READ_ACTIVATE(proct->revstddiag);
}
return ORTE_SUCCESS;

Просмотреть файл

@ -14,6 +14,8 @@
* reserved.
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -190,9 +192,12 @@ SETUP:
* because one of the readevents fires -prior- to all of them having
* been defined!
*/
if (NULL != proct->revstdout && NULL != proct->revstderr && NULL != proct->revstddiag) {
if (NULL != proct->revstdout && NULL != proct->revstddiag &&
(orte_iof_base.redirect_app_stderr_to_stdout || NULL != proct->revstderr)) {
ORTE_IOF_READ_ACTIVATE(proct->revstdout);
ORTE_IOF_READ_ACTIVATE(proct->revstderr);
if (!orte_iof_base.redirect_app_stderr_to_stdout) {
ORTE_IOF_READ_ACTIVATE(proct->revstderr);
}
ORTE_IOF_READ_ACTIVATE(proct->revstddiag);
}
return ORTE_SUCCESS;

Просмотреть файл

@ -472,7 +472,9 @@ static int do_parent(orte_odls_spawn_caddy_t *cd, int read_fd)
close(cd->opts.p_stdin[0]);
}
close(cd->opts.p_stdout[1]);
close(cd->opts.p_stderr[1]);
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
close(cd->opts.p_stderr[1]);
}
close(cd->opts.p_internal[1]);
/* Block reading a message from the pipe */

Просмотреть файл

@ -453,7 +453,9 @@ static int do_parent(orte_odls_spawn_caddy_t *cd, int read_fd)
close(cd->opts.p_stdin[0]);
}
close(cd->opts.p_stdout[1]);
close(cd->opts.p_stderr[1]);
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
close(cd->opts.p_stderr[1]);
}
close(cd->opts.p_internal[1]);
/* Block reading a message from the pipe */