From 7a139d6cc8edb850aae8f7255f34ed00ca1cb219 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Wed, 26 Apr 2006 15:36:06 +0000 Subject: [PATCH] - corrections to I/O forwarding - handling of incomplete writes THESE CHANGES SHOULD BE PROPOGATED TO BOTH 1.0 and 1.1 BRANCHES This commit was SVN r9734. --- orte/mca/iof/base/iof_base_endpoint.c | 22 ++++++++++++++-------- orte/mca/iof/base/iof_base_fragment.h | 3 +++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/orte/mca/iof/base/iof_base_endpoint.c b/orte/mca/iof/base/iof_base_endpoint.c index 34dcbcc836..a63d0f57c2 100644 --- a/orte/mca/iof/base/iof_base_endpoint.c +++ b/orte/mca/iof/base/iof_base_endpoint.c @@ -481,6 +481,7 @@ int orte_iof_base_endpoint_forward( frag->frag_owner = endpoint; frag->frag_src = *src; frag->frag_hdr.hdr_msg = *hdr; + frag->frag_len = len; /* call any registered callbacks */ for(item = opal_list_get_first(&endpoint->ep_callbacks); @@ -498,6 +499,7 @@ int orte_iof_base_endpoint_forward( if(endpoint->ep_fd >= 0) { /* try to write w/out copying data */ + if(opal_list_get_size(&endpoint->ep_frags) == 0) { if(len == 0) { ORTE_IOF_BASE_FRAG_RETURN(frag); @@ -506,15 +508,19 @@ int orte_iof_base_endpoint_forward( return ORTE_SUCCESS; } rc = write(endpoint->ep_fd,data,len); - if(rc < 0 && (errno != EAGAIN && errno != EINTR)) { - ORTE_IOF_BASE_FRAG_RETURN(frag); - orte_iof_base_endpoint_closed(endpoint); - OPAL_THREAD_UNLOCK(&orte_iof_base.iof_lock); - return ORTE_SUCCESS; - } - } + if(rc < 0) { + if (errno != EAGAIN && errno != EINTR) { + ORTE_IOF_BASE_FRAG_RETURN(frag); + orte_iof_base_endpoint_closed(endpoint); + OPAL_THREAD_UNLOCK(&orte_iof_base.iof_lock); + return ORTE_SUCCESS; + } + rc = 0; + } else { + frag->frag_len -= rc; + } + } - frag->frag_len = len - rc; if(frag->frag_len > 0 || len == 0) { /* handle incomplete write - also queue up 0 byte message * and recognize this as a request to close the descriptor diff --git a/orte/mca/iof/base/iof_base_fragment.h b/orte/mca/iof/base/iof_base_fragment.h index 1a0b294f7e..8268a8b4bb 100644 --- a/orte/mca/iof/base/iof_base_fragment.h +++ b/orte/mca/iof/base/iof_base_fragment.h @@ -39,6 +39,9 @@ OBJ_CLASS_DECLARATION(orte_iof_base_frag_t); if((frag = (orte_iof_base_frag_t*)item) == NULL) { \ opal_output(0, "ORTE_IOF_BASE_FRAG_ALLOC failed with status=%d\n", rc); \ } \ + frag->frag_owner = NULL; \ + frag->frag_ptr = frag->frag_data; \ + frag->frag_len = 0; \ } #define ORTE_IOF_BASE_FRAG_RETURN(frag) \