From 501f98d4b7c3acfc0911eac7eeaeb04ed91f60c8 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Fri, 22 Nov 2024 13:34:36 -0600 Subject: [PATCH] backend: Handle rpc_err from statedata The error return wasn't properly being generated in the statedata case. Signed-off-by: Corey Minyard --- apps/backend/backend_plugin.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c index db48562a..25962e45 100644 --- a/apps/backend/backend_plugin.c +++ b/apps/backend/backend_plugin.c @@ -295,7 +295,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp, if (fn(h, nsc, xpath, x) < 0){ if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0) goto done; - if (clixon_err_category() < 0) + if (clixon_err_category() < 0 && !plugin_rpc_err_set()) clixon_log(h, LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clixon_err call", __FUNCTION__, clixon_plugin_name_get(cp)); goto fail; /* Dont quit here on user callbacks */ @@ -354,9 +354,14 @@ clixon_plugin_statedata_all(clixon_handle h, clixon_err(OE_UNIX, errno, "cbuf_new"); goto done; } - /* error reason should be in clixon_err_reason */ - cprintf(cberr, "Internal error, state callback in plugin %s returned invalid XML: %s", - clixon_plugin_name_get(cp), clixon_err_reason()); + if (plugin_rpc_err_set()) { + if (netconf_gen_rpc_err(cberr) < 0) + goto done; + } else { + /* error reason should be in clixon_err_reason */ + cprintf(cberr, "Internal error, state callback in plugin %s returned invalid XML: %s", + clixon_plugin_name_get(cp), clixon_err_reason()); + } if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0) goto done; xml_free(*xret);