From 101b6fdeb8eb618cf6d200c5b80cb87f19dcab91 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 14 Nov 2008 14:31:33 +0000 Subject: [PATCH] Cleanup a little on how we handle the stdin write when we encounter end-of-input. Ensure that mpirun handles it correctly if the proc receiving stdin is local to mpirun This commit was SVN r19996. --- orte/mca/iof/hnp/iof_hnp.c | 26 +++++++++++++++----------- orte/mca/iof/orted/iof_orted.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/orte/mca/iof/hnp/iof_hnp.c b/orte/mca/iof/hnp/iof_hnp.c index c0256583c9..a6a8a16c72 100644 --- a/orte/mca/iof/hnp/iof_hnp.c +++ b/orte/mca/iof/hnp/iof_hnp.c @@ -264,9 +264,9 @@ static int hnp_pull(const orte_process_name_t* dst_name, } OPAL_OUTPUT_VERBOSE((1, orte_iof_base.iof_output, - "%s hnp:pull setting up %s to pass stdin", + "%s hnp:pull setting up %s to pass stdin to fd %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), - ORTE_NAME_PRINT(dst_name))); + ORTE_NAME_PRINT(dst_name), fd)); /* set the file descriptor to non-blocking - do this before we setup * the sink in case it fires right away @@ -359,6 +359,10 @@ static void stdin_write_handler(int fd, short event, void *cbdata) goto DEPART; } num_written = write(wev->fd, output->data, output->numbytes); + OPAL_OUTPUT_VERBOSE((1, orte_iof_base.iof_output, + "%s hnp:stdin:write:handler wrote %d bytes", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), + num_written)); if (num_written < 0) { if (EAGAIN == errno || EINTR == errno) { /* push this item back on the front of the list */ @@ -368,11 +372,14 @@ static void stdin_write_handler(int fd, short event, void *cbdata) */ goto CHECK; } - /* otherwise, something bad happened so all we can do is abort - * this attempt + /* otherwise, something bad happened so all we can do is declare an + * error and abort */ OBJ_RELEASE(output); - goto ABORT; + close(wev->fd); + opal_event_del(&wev->ev); + wev->pending = false; + goto DEPART; } else if (num_written < output->numbytes) { OPAL_OUTPUT_VERBOSE((1, orte_iof_base.iof_output, "incomplete write %d - adjusting data", num_written)); @@ -387,13 +394,10 @@ static void stdin_write_handler(int fd, short event, void *cbdata) } OBJ_RELEASE(output); } -ABORT: - close(wev->fd); - opal_event_del(&wev->ev); - wev->pending = false; - + CHECK: - if (!mca_iof_hnp_component.stdinev->active) { + if (NULL != mca_iof_hnp_component.stdinev && + !mca_iof_hnp_component.stdinev->active) { OPAL_OUTPUT_VERBOSE((1, orte_iof_base.iof_output, "read event is off - checking if okay to restart")); /* if we have turned off the read event, check to diff --git a/orte/mca/iof/orted/iof_orted.c b/orte/mca/iof/orted/iof_orted.c index 36b5916b3a..728a327886 100644 --- a/orte/mca/iof/orted/iof_orted.c +++ b/orte/mca/iof/orted/iof_orted.c @@ -260,11 +260,16 @@ static void stdin_write_handler(int fd, short event, void *cbdata) */ goto CHECK; } - /* otherwise, something bad happened so all we can do is abort - * this attempt + /* otherwise, something bad happened so all we can do is declare an + * error and abort */ OBJ_RELEASE(output); - goto ABORT; + close(wev->fd); + opal_event_del(&wev->ev); + wev->pending = false; + /* tell the HNP to stop sending us stuff */ + /* tell ourselves to dump anything that arrives */ + goto DEPART; } else if (num_written < output->numbytes) { /* incomplete write - adjust data to avoid duplicate output */ memmove(output->data, &output->data[num_written], output->numbytes - num_written); @@ -277,11 +282,6 @@ static void stdin_write_handler(int fd, short event, void *cbdata) } OBJ_RELEASE(output); } - goto CHECK; /* don't abort yet. Spurious event might happens */ -ABORT: - close(wev->fd); - opal_event_del(&wev->ev); - wev->pending = false; CHECK: if (mca_iof_orted_component.xoff) {