Commit 810dcf24 authored by andrey.lobanov's avatar andrey.lobanov Committed by Kenneth Raffenetti
Browse files

fixed memory leaks in pmi messages handling



  - name publishing/lookup support (pmi v1 and v2)
  - job and node attrs (v2)

Change-Id: Id18d968da0d0bbf6e8cb2e7acffaf77d82a5e8b0
Signed-off-by: Kenneth Raffenetti's avatarKen Raffenetti <raffenet@mcs.anl.gov>
parent 32788e87
......@@ -19,7 +19,7 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
{
int i, sent, closed;
struct HYD_string_stash stash;
char *buf;
char *buf = NULL;
struct HYD_pmcd_hdr hdr;
HYD_status status = HYD_SUCCESS;
......@@ -56,6 +56,8 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
HYDU_ASSERT(!closed, status);
fn_exit:
if (buf)
HYDU_FREE(buf);
HYDU_FUNC_EXIT();
return status;
......@@ -216,7 +218,7 @@ static HYD_status fn_job_getid(int fd, char *args[])
{
struct HYD_string_stash stash;
char *cmd, *thrid;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
int token_count;
HYD_status status = HYD_SUCCESS;
......@@ -244,6 +246,8 @@ static HYD_status fn_job_getid(int fd, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......@@ -255,7 +259,7 @@ static HYD_status fn_info_putnodeattr(int fd, char *args[])
{
struct HYD_string_stash stash;
char *key, *val, *thrid, *cmd;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
int token_count, ret;
struct HYD_pmcd_pmi_v2_reqs *req;
HYD_status status = HYD_SUCCESS;
......@@ -302,6 +306,8 @@ static HYD_status fn_info_putnodeattr(int fd, char *args[])
}
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......@@ -316,7 +322,7 @@ static HYD_status fn_info_getnodeattr(int fd, char *args[])
char *key, *waitval, *thrid;
struct HYD_string_stash stash;
char *cmd;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
int token_count;
HYD_status status = HYD_SUCCESS;
......@@ -384,6 +390,8 @@ static HYD_status fn_info_getnodeattr(int fd, char *args[])
}
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......@@ -446,7 +454,7 @@ static HYD_status fn_finalize(int fd, char *args[])
char *thrid;
struct HYD_string_stash stash;
char *cmd;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
int token_count;
HYD_status status = HYD_SUCCESS;
......@@ -476,6 +484,8 @@ static HYD_status fn_finalize(int fd, char *args[])
close(fd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......
......@@ -629,8 +629,8 @@ static HYD_status fn_publish_name(int fd, int pid, int pgid, char *args[])
struct HYD_string_stash stash;
char *cmd, *val;
int token_count;
struct HYD_pmcd_token *tokens;
char *name, *port;
struct HYD_pmcd_token *tokens = NULL;
char *name = NULL, *port = NULL;
int success = 0;
HYD_status status = HYD_SUCCESS;
......@@ -666,6 +666,13 @@ static HYD_status fn_publish_name(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
if (name)
HYDU_FREE(name);
if (port)
HYDU_FREE(port);
HYDU_FUNC_EXIT();
return status;
......@@ -678,7 +685,7 @@ static HYD_status fn_unpublish_name(int fd, int pid, int pgid, char *args[])
struct HYD_string_stash stash;
char *cmd, *name;
int token_count;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
int success = 0;
HYD_status status = HYD_SUCCESS;
......@@ -709,6 +716,8 @@ static HYD_status fn_unpublish_name(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......@@ -719,9 +728,9 @@ static HYD_status fn_unpublish_name(int fd, int pid, int pgid, char *args[])
static HYD_status fn_lookup_name(int fd, int pid, int pgid, char *args[])
{
struct HYD_string_stash stash;
char *cmd, *name, *value;
char *cmd, *name, *value = NULL;
int token_count;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
HYD_status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -753,6 +762,10 @@ static HYD_status fn_lookup_name(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
if (value)
HYDU_FREE(value);
HYDU_FUNC_EXIT();
return status;
......
......@@ -747,9 +747,9 @@ static HYD_status fn_spawn(int fd, int pid, int pgid, char *args[])
static HYD_status fn_name_publish(int fd, int pid, int pgid, char *args[])
{
struct HYD_string_stash stash;
char *cmd, *thrid, *val, *name, *port;
char *cmd, *thrid, *val, *name = NULL, *port = NULL;
int token_count, success;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
HYD_status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -792,6 +792,12 @@ static HYD_status fn_name_publish(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
if (name)
HYDU_FREE(name);
if (port)
HYDU_FREE(port);
HYDU_FUNC_EXIT();
return status;
......@@ -804,7 +810,7 @@ static HYD_status fn_name_unpublish(int fd, int pid, int pgid, char *args[])
struct HYD_string_stash stash;
char *cmd, *thrid, *name;
int token_count, success;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
HYD_status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -842,6 +848,8 @@ static HYD_status fn_name_unpublish(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......@@ -853,9 +861,8 @@ static HYD_status fn_name_lookup(int fd, int pid, int pgid, char *args[])
{
struct HYD_string_stash stash;
char *cmd, *thrid, *name, *value;
struct HYD_pmcd_pmi_publish *publish;
int token_count;
struct HYD_pmcd_token *tokens;
struct HYD_pmcd_token *tokens = NULL;
HYD_status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -865,9 +872,6 @@ static HYD_status fn_name_lookup(int fd, int pid, int pgid, char *args[])
thrid = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "thrid");
HYDU_MALLOC(publish, struct HYD_pmcd_pmi_publish *, sizeof(struct HYD_pmcd_pmi_publish),
status);
if ((name = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "name")) == NULL)
HYDU_ERR_POP(status, "cannot find token: name\n");
......@@ -897,6 +901,8 @@ static HYD_status fn_name_lookup(int fd, int pid, int pgid, char *args[])
HYDU_FREE(cmd);
fn_exit:
if (tokens)
HYD_pmcd_pmi_free_tokens(tokens, token_count);
HYDU_FUNC_EXIT();
return status;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment