From 0a77b5453546795b0ceed0a6af0e03facf72923d Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Mon, 18 Apr 2005 18:57:24 +0000 Subject: [PATCH] fix two bugs for dynamic process management, which makes the ibm spawn test pass: - argv[0] should be the name of the executable for the spawned processes. - if we free a dynamic communicator (instead of disconnecting), the counter for dynamic communicators has to be decreased as well, else we core in finalize. This commit was SVN r5419. --- src/communicator/comm.c | 16 ++++++++------ src/communicator/comm_dyn.c | 43 +++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/communicator/comm.c b/src/communicator/comm.c index 1145424e88..5674324227 100644 --- a/src/communicator/comm.c +++ b/src/communicator/comm.c @@ -733,7 +733,9 @@ int ompi_comm_free ( ompi_communicator_t **comm ) } /* Release the communicator */ - + if ( OMPI_COMM_IS_DYNAMIC (*comm) ) { + ompi_comm_num_dyncomm --; + } OBJ_RELEASE ( (*comm) ); *comm = MPI_COMM_NULL; @@ -878,12 +880,12 @@ ompi_proc_t **ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, /**********************************************************************/ /**********************************************************************/ /**********************************************************************/ - /** - * This routine verifies, whether local_group and remote group are overlapping - * in intercomm_create - */ - int ompi_comm_overlapping_groups (int size, ompi_proc_t **lprocs, - int rsize, ompi_proc_t ** rprocs) +/** + * This routine verifies, whether local_group and remote group are overlapping + * in intercomm_create + */ +int ompi_comm_overlapping_groups (int size, ompi_proc_t **lprocs, + int rsize, ompi_proc_t ** rprocs) { int rc=OMPI_SUCCESS; diff --git a/src/communicator/comm_dyn.c b/src/communicator/comm_dyn.c index 43cca6b675..04ac9d0958 100644 --- a/src/communicator/comm_dyn.c +++ b/src/communicator/comm_dyn.c @@ -60,7 +60,7 @@ int ompi_comm_connect_accept ( ompi_communicator_t *comm, int root, ompi_proc_t **rprocs=NULL; ompi_group_t *group=comm->c_local_group; orte_process_name_t *rport=NULL; - orte_buffer_t *nbuf, *nrbuf; + orte_buffer_t *nbuf=NULL, *nrbuf=NULL; size = ompi_comm_size ( comm ); rank = ompi_comm_rank ( comm ); @@ -344,32 +344,37 @@ ompi_comm_start_processes(int count, char **array_of_commands, } /* record the number of procs to be generated */ apps[i]->num_procs = array_of_maxprocs[i]; + /* copy over the argv array */ + apps[i]->argc = 1; + if (MPI_ARGVS_NULL != array_of_argv && MPI_ARGV_NULL != array_of_argv[i]) { /* first need to find out how many entries there are */ - apps[i]->argc = 0; j=0; while (NULL != array_of_argv[i][j]) { j++; } - apps[i]->argc = j; - apps[i]->argv = NULL; - /* now copy them over, ensuring to NULL terminate the array */ - if (0 < j) { - apps[i]->argv = (char**)malloc((1 + apps[i]->argc) * sizeof(char*)); - if (NULL == apps[i]->argv) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - /* rollback what was already done */ - for (j=0; j < i; j++) OBJ_RELEASE(apps[j]); - return ORTE_ERR_OUT_OF_RESOURCE; - } - for (j=0; j < apps[i]->argc; j++) { - apps[i]->argv[j] = strdup(array_of_argv[i][j]); - } - apps[i]->argv[apps[i]->argc] = NULL; - } - } + apps[i]->argc += j; + } + + /* now copy them over, ensuring to NULL terminate the array */ + apps[i]->argv = (char**)malloc((1 + apps[i]->argc) * sizeof(char*)); + if (NULL == apps[i]->argv) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + /* rollback what was already done */ + for (j=0; j < i; j++) { + OBJ_RELEASE(apps[j]); + } + return ORTE_ERR_OUT_OF_RESOURCE; + } + apps[i]->argv[0] = strdup(array_of_commands[i]); + for (j=1; j < apps[i]->argc; j++) { + apps[i]->argv[j] = strdup(array_of_argv[i][j-1]); + } + apps[i]->argv[apps[i]->argc] = NULL; + + /* the environment gets set by the launcher * all we need to do is add the specific values * needed for comm_spawn