diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index 1bda0f73..03e318cf 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -612,20 +612,27 @@ candidate_validate(clicon_handle h, * use clicon_err. */ if (xret && clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0) goto done; - plugin_transaction_abort_all(h, td); if (!cbuf_len(cbret) && netconf_operation_failed(cbret, "application", clicon_err_reason)< 0) goto done; goto fail; } if (xmldb_get0_clear(h, td->td_src) < 0 || - xmldb_get0_clear(h, td->td_target) < 0){ - plugin_transaction_abort_all(h, td); + xmldb_get0_clear(h, td->td_target) < 0) goto done; - } + plugin_transaction_end_all(h, td); retval = 1; done: + if (xret) + xml_free(xret); + if (td){ + if (retval < 1) + plugin_transaction_abort_all(h, td); + xmldb_get0_free(h, &td->td_target); + xmldb_get0_free(h, &td->td_src); + transaction_free(td); + } return retval; fail: retval = 0; diff --git a/apps/backend/backend_plugin_restconf.c b/apps/backend/backend_plugin_restconf.c index 084d6c9c..6b82417d 100644 --- a/apps/backend/backend_plugin_restconf.c +++ b/apps/backend/backend_plugin_restconf.c @@ -270,11 +270,11 @@ restconf_pseudo_process_control(clicon_handle h) * see restconf_pseudo_set_log which sets flag when process starts */ argv[i++] = "-D"; - argv[i++] = strdup("0"); + argv[i++] = "0"; argv[i++] = "-l"; - argv[i++] = strdup("s"); /* There is also log-destination in clixon-restconf.yang */ + argv[i++] = "s"; /* There is also log-destination in clixon-restconf.yang */ argv[i++] = "-R"; - argv[i++] = strdup(""); + argv[i++] = ""; argv[i++] = NULL; assert(i==nr); if (clixon_process_register(h, RESTCONF_PROCESS, diff --git a/lib/src/clixon_proc.c b/lib/src/clixon_proc.c index 29dd9320..b96fc877 100644 --- a/lib/src/clixon_proc.c +++ b/lib/src/clixon_proc.c @@ -682,48 +682,53 @@ clixon_process_status(clicon_handle h, int run; int i; char timestr[28]; + int match = 0; - if (_proc_entry_list == NULL) - goto ok; - pe = _proc_entry_list; - do { - if (strcmp(pe->pe_name, name) == 0){ - /* Check if running */ - run = 0; - if (pe->pe_pid && proc_op_run(pe->pe_pid, &run) < 0) - goto done; - cprintf(cbret, "%s", - NETCONF_BASE_NAMESPACE, CLIXON_LIB_NS, run?"true":"false"); - if (pe->pe_description) - cprintf(cbret, "%s", CLIXON_LIB_NS, pe->pe_description); - cprintf(cbret, "", CLIXON_LIB_NS); - /* the command may include any data, including XML (such as restconf -R command) and - therefore needs CDATA encoding */ - cprintf(cbret, "pe_argc-1; i++){ - if (i) - cprintf(cbret, " "); - cprintf(cbret, "%s", pe->pe_argv[i]); - } - cprintf(cbret, "]]>"); - cprintf(cbret, ""); - cprintf(cbret, "%s", CLIXON_LIB_NS, - clicon_int2str(proc_state_map, pe->pe_state)); - if (timerisset(&pe->pe_starttime)){ - if (time2str(pe->pe_starttime, timestr, sizeof(timestr)) < 0){ - clicon_err(OE_UNIX, errno, "time2str"); + if (_proc_entry_list != NULL){ + pe = _proc_entry_list; + do { + if (strcmp(pe->pe_name, name) == 0){ + /* Check if running */ + run = 0; + if (pe->pe_pid && proc_op_run(pe->pe_pid, &run) < 0) goto done; + cprintf(cbret, "%s", + NETCONF_BASE_NAMESPACE, CLIXON_LIB_NS, run?"true":"false"); + if (pe->pe_description) + cprintf(cbret, "%s", CLIXON_LIB_NS, pe->pe_description); + cprintf(cbret, "", CLIXON_LIB_NS); + /* the command may include any data, including XML (such as restconf -R command) and + therefore needs CDATA encoding */ + cprintf(cbret, "pe_argc-1; i++){ + if (i) + cprintf(cbret, " "); + cprintf(cbret, "%s", pe->pe_argv[i]); } - cprintf(cbret, "%s", CLIXON_LIB_NS, timestr); + cprintf(cbret, "]]>"); + cprintf(cbret, ""); + cprintf(cbret, "%s", CLIXON_LIB_NS, + clicon_int2str(proc_state_map, pe->pe_state)); + if (timerisset(&pe->pe_starttime)){ + if (time2str(pe->pe_starttime, timestr, sizeof(timestr)) < 0){ + clicon_err(OE_UNIX, errno, "time2str"); + goto done; + } + cprintf(cbret, "%s", CLIXON_LIB_NS, timestr); + } + if (pe->pe_pid) + cprintf(cbret, "%u", CLIXON_LIB_NS, pe->pe_pid); + cprintf(cbret, ""); + match++; + break; /* hit break here */ } - if (pe->pe_pid) - cprintf(cbret, "%u", CLIXON_LIB_NS, pe->pe_pid); - cprintf(cbret, ""); - break; /* hit break here */ - } - pe = NEXTQ(process_entry_t *, pe); - } while (pe != _proc_entry_list); - ok: + pe = NEXTQ(process_entry_t *, pe); + } while (pe != _proc_entry_list); + } + if (!match){ /* No match, return error */ + if (netconf_unknown_element(cbret, "application", (char*)name, "Process service is not known") < 0) + goto done; + } retval = 0; done: clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);