From 1a422995aedc35e0c03ea5f19a8ddc061df2e38a Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 10 Jun 2008 17:53:28 +0000 Subject: [PATCH] Fix two Coverity complaints CID 813 (value defined and not used) and 1039 (resource leak). While doing so, found and fixed another less obvious memory leak. This commit was SVN r18641. --- orte/mca/plm/base/plm_base_orted_cmds.c | 3 ++- orte/tools/orterun/orterun.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/orte/mca/plm/base/plm_base_orted_cmds.c b/orte/mca/plm/base/plm_base_orted_cmds.c index 41a2fe951c..d97fdd74df 100644 --- a/orte/mca/plm/base/plm_base_orted_cmds.c +++ b/orte/mca/plm/base/plm_base_orted_cmds.c @@ -72,7 +72,8 @@ static void send_callback(int status, if (num_reported == num_being_sent) { /* cancel the timer */ if (NULL != ev) { - opal_event_del(ev); + opal_evtimer_del(ev); + free(ev); ev = NULL; } diff --git a/orte/tools/orterun/orterun.c b/orte/tools/orterun/orterun.c index 2bd86e2390..ce08706cd2 100644 --- a/orte/tools/orterun/orterun.c +++ b/orte/tools/orterun/orterun.c @@ -114,6 +114,8 @@ static opal_event_t *orterun_event, *orteds_exit_event; static char *ompi_server=NULL; static opal_event_t *abort_exit_event=NULL; static bool forcibly_die = false; +static opal_event_t *timeout_ev=NULL; + /* * Globals */ @@ -571,8 +573,10 @@ static void job_completed(int trigpipe, short event, void *arg) /* if the abort exit event is set, delete it */ if (NULL != abort_exit_event) { - opal_event_del(abort_exit_event); + opal_evtimer_del(abort_exit_event); + free(abort_exit_event); } + /* close the trigger pipe */ if (0 <= trigpipe) { close(trigpipe); @@ -612,9 +616,7 @@ static void job_completed(int trigpipe, short event, void *arg) goto DONE; } - if (ORTE_SUCCESS != (rc = orte_plm.terminate_orteds())) { - opal_event_t *ev; - + if (ORTE_SUCCESS != (rc = orte_plm.terminate_orteds())) { /* since we know that the sends didn't completely go out, * we know that the prior event will never fire. Delete it * for completeness, and replace it with a timeout so @@ -627,7 +629,7 @@ static void job_completed(int trigpipe, short event, void *arg) /* we are totally hozed */ goto DONE; } - ORTE_DETECT_TIMEOUT(&ev, daemons->num_procs, + ORTE_DETECT_TIMEOUT(&timeout_ev, daemons->num_procs, orte_timeout_usec_per_proc, orte_max_timeout, terminated); } @@ -667,6 +669,12 @@ static void terminated(int trigpipe, short event, void *arg) close(trigpipe); } + /* clear the event timer */ + if (NULL != timeout_ev) { + opal_evtimer_del(timeout_ev); + free(timeout_ev); + } + /* Remove the TERM and INT signal handlers */ opal_signal_del(&term_handler); opal_signal_del(&int_handler); @@ -1560,11 +1568,13 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr, if (0 == param_len) { orte_show_help("help-orterun.txt", "orterun:empty-prefix", true, orterun_basename, orterun_basename); + free(param); return ORTE_ERR_FATAL; } } app->prefix_dir = strdup(param); + free(param); } }