From f27ccd2e1c27f5e9473bc4cf72982c990d435b6a Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 24 Jul 2024 17:28:41 -0500 Subject: [PATCH] Update error handling for prdcr_listen_add Add error case when user attempts to create a producer listen that already exists. --- ldms/src/ldmsd/ldmsd_request.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ldms/src/ldmsd/ldmsd_request.c b/ldms/src/ldmsd/ldmsd_request.c index f88c3b91e..fc89f7d3c 100644 --- a/ldms/src/ldmsd/ldmsd_request.c +++ b/ldms/src/ldmsd/ldmsd_request.c @@ -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")) || @@ -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,