From a3607ff35d93cc61a2fb08c97a1216bd302b661c Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 15 Feb 2011 13:26:11 +0000 Subject: [PATCH] Make it easier to send a kill-local-procs command for an arbitrary number of procs This commit was SVN r24386. --- orte/mca/plm/base/plm_base_orted_cmds.c | 26 -------------- orte/orted/orted_comm.c | 47 +++++++++++-------------- 2 files changed, 21 insertions(+), 52 deletions(-) diff --git a/orte/mca/plm/base/plm_base_orted_cmds.c b/orte/mca/plm/base/plm_base_orted_cmds.c index 9bd0c1bc55..088c4a23a6 100644 --- a/orte/mca/plm/base/plm_base_orted_cmds.c +++ b/orte/mca/plm/base/plm_base_orted_cmds.c @@ -257,7 +257,6 @@ int orte_plm_base_orted_kill_local_procs(opal_pointer_array_t *procs) orte_process_name_t peer; orte_job_t *daemons; orte_proc_t *proc; - int32_t num_procs=0; OPAL_OUTPUT_VERBOSE((5, orte_plm_globals.output, "%s plm:base:orted_cmd sending kill_local_procs cmds", @@ -272,31 +271,6 @@ int orte_plm_base_orted_kill_local_procs(opal_pointer_array_t *procs) return rc; } - if (NULL != procs) { - /* count the number of procs */ - for (v=0; v < procs->size; v++) { - if (NULL == opal_pointer_array_get_item(procs, v)) { - continue; - } - num_procs++; - } - - /* bozo check */ - if (0 == num_procs) { - OPAL_OUTPUT_VERBOSE((5, orte_plm_globals.output, - "%s plm:base:orted_cmd:kill_local_procs no procs given", - ORTE_NAME_PRINT(ORTE_PROC_MY_NAME))); - return ORTE_SUCCESS; - } - } - - /* pack the number of procs */ - if (ORTE_SUCCESS != (rc = opal_dss.pack(&cmd, &num_procs, 1, OPAL_INT32))) { - ORTE_ERROR_LOG(rc); - OBJ_DESTRUCT(&cmd); - return rc; - } - /* pack the proc names */ if (NULL != procs) { for (v=0; v < procs->size; v++) { diff --git a/orte/orted/orted_comm.c b/orte/orted/orted_comm.c index ec3ef02c39..41681bdeeb 100644 --- a/orte/orted/orted_comm.c +++ b/orte/orted/orted_comm.c @@ -390,11 +390,23 @@ int orte_daemon_process_commands(orte_process_name_t* sender, /**** KILL_LOCAL_PROCS ****/ case ORTE_DAEMON_KILL_LOCAL_PROCS: - /* unpack the number of procs */ - n = 1; - if (ORTE_SUCCESS != (ret = opal_dss.unpack(buffer, &num_replies, &n, OPAL_INT32))) { + num_replies = 0; + + /* construct the pointer array */ + OBJ_CONSTRUCT(&procarray, opal_pointer_array_t); + opal_pointer_array_init(&procarray, num_replies, ORTE_GLOBAL_ARRAY_MAX_SIZE, 16); + + /* unpack the proc names into the array */ + while (ORTE_SUCCESS == (ret = opal_dss.unpack(buffer, &proc, &n, ORTE_NAME))) { + proct = OBJ_NEW(orte_proc_t); + proct->name.jobid = proc.jobid; + proct->name.vpid = proc.vpid; + opal_pointer_array_add(&procarray, proct); + num_replies++; + } + if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != ret) { ORTE_ERROR_LOG(ret); - goto CLEANUP; + goto KILL_PROC_CLEANUP; } if (0 == num_replies) { @@ -403,30 +415,13 @@ int orte_daemon_process_commands(orte_process_name_t* sender, ORTE_ERROR_LOG(ret); } break; + } else { + /* kill the procs */ + if (ORTE_SUCCESS != (ret = orte_odls.kill_local_procs(&procarray))) { + ORTE_ERROR_LOG(ret); + } } - /* construct the pointer array */ - OBJ_CONSTRUCT(&procarray, opal_pointer_array_t); - opal_pointer_array_init(&procarray, num_replies, ORTE_GLOBAL_ARRAY_MAX_SIZE, 16); - - /* unpack the proc names into the array */ - for (i=0; i < num_replies; i++) { - n = 1; - if (ORTE_SUCCESS != (ret = opal_dss.unpack(buffer, &proc, &n, ORTE_NAME))) { - ORTE_ERROR_LOG(ret); - goto KILL_PROC_CLEANUP; - } - proct = OBJ_NEW(orte_proc_t); - proct->name.jobid = proc.jobid; - proct->name.vpid = proc.vpid; - opal_pointer_array_add(&procarray, proct); - } - - /* kill the procs */ - if (ORTE_SUCCESS != (ret = orte_odls.kill_local_procs(&procarray))) { - ORTE_ERROR_LOG(ret); - } - /* cleanup */ KILL_PROC_CLEANUP: for (i=0; i < procarray.size; i++) {