Skip to content

Commit

Permalink
Update error handling for prdcr_listen_add
Browse files Browse the repository at this point in the history
Add error case when user attempts to create a producer listen that already exists.
  • Loading branch information
nick-enoent committed Jul 24, 2024
1 parent 27042d9 commit 68008df
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ldms/src/ldmsd/ldmsd_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -9514,8 +9514,12 @@ static int prdcr_listen_add_handler(ldmsd_req_ctxt_t reqc)
pl = (ldmsd_prdcr_listen_t)
ldmsd_cfgobj_new_with_auth(name, LDMSD_CFGOBJ_PRDCR_LISTEN,
sizeof(*pl), NULL, 0, 0, 0);
if (!pl)
goto enomem;
if (!pl) {
if (errno == EEXIST)
goto eexist;
else
goto enomem;
}
pl->auto_start = 1;
if (disabled_start) {
if ((0 == strcmp(disabled_start, "1")) ||
Expand Down Expand Up @@ -9578,6 +9582,11 @@ static int prdcr_listen_add_handler(ldmsd_req_ctxt_t reqc)
(void)snprintf(reqc->line_buf, reqc->line_len,
"Memory allocation failed.");
goto send_reply;
eexist:
reqc->errcode = EEXIST;
(void)snprintf(reqc->line_buf, reqc->line_len,
"The prdcr listener %s already exists.", name);
goto send_reply;
einval:
reqc->errcode = EINVAL;
(void) snprintf(reqc->line_buf, reqc->line_len,
Expand Down

0 comments on commit 68008df

Please sign in to comment.