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>
Этот коммит содержится в:
родитель
84e96522f2
Коммит
e88767866e
@ -113,9 +113,11 @@ orte_iof_base_setup_prefork(orte_iof_base_io_conf_t *opts)
|
|||||||
return ORTE_ERR_SYS_LIMITS_PIPES;
|
return ORTE_ERR_SYS_LIMITS_PIPES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pipe(opts->p_stderr) < 0) {
|
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
|
||||||
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
|
if (pipe(opts->p_stderr) < 0) {
|
||||||
return ORTE_ERR_SYS_LIMITS_PIPES;
|
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
|
||||||
|
return ORTE_ERR_SYS_LIMITS_PIPES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (pipe(opts->p_internal) < 0) {
|
if (pipe(opts->p_internal) < 0) {
|
||||||
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
|
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_stdin[1]);
|
||||||
}
|
}
|
||||||
close(opts->p_stdout[0]);
|
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]);
|
close(opts->p_internal[0]);
|
||||||
|
|
||||||
if (opts->usepty) {
|
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 ) {
|
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
|
||||||
ret = dup2(opts->p_stderr[1], fileno(stderr));
|
ret = dup2(opts->p_stderr[1], fileno(stderr));
|
||||||
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
|
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 ) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = orte_iof.push(name, ORTE_IOF_STDERR, opts->p_stderr[0]);
|
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
|
||||||
if(ORTE_SUCCESS != ret) {
|
ret = orte_iof.push(name, ORTE_IOF_STDERR, opts->p_stderr[0]);
|
||||||
ORTE_ERROR_LOG(ret);
|
if(ORTE_SUCCESS != ret) {
|
||||||
return ret;
|
ORTE_ERROR_LOG(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = orte_iof.push(name, ORTE_IOF_STDDIAG, opts->p_internal[0]);
|
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
|
* because one of the readevents fires -prior- to all of them having
|
||||||
* been defined!
|
* 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) {
|
if (proct->copy) {
|
||||||
/* see if there are any wildcard subscribers out there that
|
/* see if there are any wildcard subscribers out there that
|
||||||
* apply to us */
|
* 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->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);
|
ORTE_IOF_READ_ACTIVATE(proct->revstddiag);
|
||||||
}
|
}
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* reserved.
|
* reserved.
|
||||||
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
|
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
|
||||||
* Copyright (c) 2017 Mellanox Technologies. 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$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -190,9 +192,12 @@ SETUP:
|
|||||||
* because one of the readevents fires -prior- to all of them having
|
* because one of the readevents fires -prior- to all of them having
|
||||||
* been defined!
|
* 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->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);
|
ORTE_IOF_READ_ACTIVATE(proct->revstddiag);
|
||||||
}
|
}
|
||||||
return ORTE_SUCCESS;
|
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_stdin[0]);
|
||||||
}
|
}
|
||||||
close(cd->opts.p_stdout[1]);
|
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]);
|
close(cd->opts.p_internal[1]);
|
||||||
|
|
||||||
/* Block reading a message from the pipe */
|
/* 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_stdin[0]);
|
||||||
}
|
}
|
||||||
close(cd->opts.p_stdout[1]);
|
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]);
|
close(cd->opts.p_internal[1]);
|
||||||
|
|
||||||
/* Block reading a message from the pipe */
|
/* Block reading a message from the pipe */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user