Ralph,

i fixed that in https://github.com/open-mpi/ompi/commit/f9ebba466817b488974b0de6f941e31419336631


Cheers,


Gilles


On 9/22/2016 6:10 PM, r...@open-mpi.org wrote:
Hey Gilles

This fix doesn’t look right to me.

+            /* we read something - better get more */
+            num_chars_read += rc;
+            orted_uri = realloc((void*)orted_uri, buffer_length+chunk);
+            memset(&orted_uri[buffer_length], 0, chunk);
+            buffer_length += chunk;
        }
Just because you read “something”, it doesn’t mean that you have to realloc the 
buffer. You might have read only a small piece, not an entire “chunk”.

What you need to do is to see if the buffer has been filled, and only read each 
time up to the remaining number of characters available in the buffer. If the 
buffer has been filled (or if you want to optimize, if the remaining space 
falls under some minimum limit), then you realloc another ORTE_URI_MSG_LNGTH 
block.


On Sep 21, 2016, at 10:25 PM, git...@open-mpi.org wrote:

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "open-mpi/ompi".

The branch, master has been updated
      via  c7bf9a0ec9940d6fe0ff6da5212fc881de73cf21 (commit)
     from  e1d89a4dcf5feeaf978e6806b08d609ecfb9889a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://github.com/open-mpi/ompi/commit/c7bf9a0ec9940d6fe0ff6da5212fc881de73cf21

commit c7bf9a0ec9940d6fe0ff6da5212fc881de73cf21
Author: Gilles Gouaillardet <gil...@rist.or.jp>
Date:   Thu Sep 22 13:18:54 2016 +0900

   ess/singleton: fix read on the pipe to spawn'ed orted

   and close the pipe on both ends when it is no more needed

diff --git a/orte/mca/ess/singleton/ess_singleton_module.c 
b/orte/mca/ess/singleton/ess_singleton_module.c
index 571d453..55c7985 100644
--- a/orte/mca/ess/singleton/ess_singleton_module.c
+++ b/orte/mca/ess/singleton/ess_singleton_module.c
@@ -571,20 +571,20 @@ static int fork_hnp(void)
        orted_uri = (char*)malloc(buffer_length);
        memset(orted_uri, 0, buffer_length);

-        while (chunk == (rc = read(p[0], &orted_uri[num_chars_read], chunk))) {
+        while (0 != (rc = read(p[0], &orted_uri[num_chars_read], chunk))) {
            if (rc < 0 && (EAGAIN == errno || EINTR == errno)) {
                continue;
-            } else {
-                num_chars_read = 0;
+            } else if (rc < 0) {
+                num_chars_read = -1;
                break;
            }
-            /* we read an entire buffer - better get more */
-            num_chars_read += chunk;
-            orted_uri = realloc((void*)orted_uri, 
buffer_length+ORTE_URI_MSG_LGTH);
-            memset(&orted_uri[buffer_length], 0, ORTE_URI_MSG_LGTH);
-            buffer_length += ORTE_URI_MSG_LGTH;
+            /* we read something - better get more */
+            num_chars_read += rc;
+            orted_uri = realloc((void*)orted_uri, buffer_length+chunk);
+            memset(&orted_uri[buffer_length], 0, chunk);
+            buffer_length += chunk;
        }
-        num_chars_read += rc;
+        close(p[0]);

        if (num_chars_read <= 0) {
            /* we didn't get anything back - this is bad */
diff --git a/orte/orted/orted_main.c b/orte/orted/orted_main.c
index 3c7bc63..0e7c318 100644
--- a/orte/orted/orted_main.c
+++ b/orte/orted/orted_main.c
@@ -628,6 +628,7 @@ int orte_daemon(int argc, char *argv[])

        /* cleanup */
        free(tmp);
+        close(orted_globals.uri_pipe);

        /* since a singleton spawned us, we need to harvest
         * any MCA params from the local environment so


-----------------------------------------------------------------------

Summary of changes:
orte/mca/ess/singleton/ess_singleton_module.c |   18 +++++++++---------
orte/orted/orted_main.c                       |    1 +
2 files changed, 10 insertions(+), 9 deletions(-)


hooks/post-receive
--
open-mpi/ompi
_______________________________________________
ompi-commits mailing list
ompi-comm...@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/ompi-commits
_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel

_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel

Reply via email to