Restart restconf daemon only if restconf config is edited (not all)

This commit is contained in:
Olof hagsand 2021-03-05 13:11:04 +01:00
parent e8cd587ded
commit 2ab90d847b
2 changed files with 14 additions and 9 deletions

View file

@ -192,7 +192,7 @@ restconf_pseudo_process_commit(clicon_handle h,
xtarget = transaction_target(td); xtarget = transaction_target(td);
if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL) if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL)
enabled++; enabled++;
/* Toggle start/stop */ /* Toggle start/stop if enable flag changed */
if ((cx = xpath_first(xtarget, NULL, "/restconf/enable")) != NULL && if ((cx = xpath_first(xtarget, NULL, "/restconf/enable")) != NULL &&
xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_ADD)){ xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_ADD)){
if (clixon_process_operation(h, RESTCONF_PROCESS, if (clixon_process_operation(h, RESTCONF_PROCESS,
@ -203,12 +203,15 @@ restconf_pseudo_process_commit(clicon_handle h,
if (transaction_dlen(xtarget) != 0 || if (transaction_dlen(xtarget) != 0 ||
transaction_alen(xtarget) != 0 || transaction_alen(xtarget) != 0 ||
transaction_clen(xtarget) != 0){ transaction_clen(xtarget) != 0){
/* A restart can terminate a restconf connection (cut the tree limb you are sitting on) if ((cx = xpath_first(xtarget, NULL, "/restconf")) != NULL &&
* Specifically, the socket is terminated where the reply is sent, which will xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_ADD)){
* cause the curl to fail. /* A restart can terminate a restconf connection (cut the tree limb you are sitting on)
*/ * Specifically, the socket is terminated where the reply is sent, which will
if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0, NULL) < 0) * cause the curl to fail.
goto done; */
if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0, NULL) < 0)
goto done;
}
} }
} }
retval = 0; retval = 0;

View file

@ -431,6 +431,7 @@ static int
clixon_process_operation_one(const proc_operation op, clixon_process_operation_one(const proc_operation op,
const char *netns, const char *netns,
char **argv, char **argv,
const char *name,
pid_t *pidp) pid_t *pidp)
{ {
int retval = -1; int retval = -1;
@ -441,7 +442,8 @@ clixon_process_operation_one(const proc_operation op,
goto done; goto done;
if (op == PROC_OP_STOP || op == PROC_OP_RESTART){ if (op == PROC_OP_STOP || op == PROC_OP_RESTART){
if (run){ if (run){
pidfile_zapold(*pidp); /* Ensures its dead */ clicon_log(LOG_NOTICE, "Killing old daemon %s with pid: %d", name, *pidp);
kill(*pidp, SIGTERM);
} }
*pidp = 0; /* mark as dead */ *pidp = 0; /* mark as dead */
run = 0; run = 0;
@ -571,7 +573,7 @@ clixon_process_sched(int fd,
pe = _proc_entry_list; pe = _proc_entry_list;
do { do {
if ((op = pe->pe_op) != PROC_OP_NONE){ if ((op = pe->pe_op) != PROC_OP_NONE){
if (clixon_process_operation_one(op, pe->pe_netns, pe->pe_argv, &pe->pe_pid) < 0) if (clixon_process_operation_one(op, pe->pe_netns, pe->pe_argv, pe->pe_name, &pe->pe_pid) < 0)
goto done; goto done;
clicon_debug(1, "%s op:%s pid:%d", __FUNCTION__, clicon_int2str(proc_operation_map, op), pe->pe_pid); clicon_debug(1, "%s op:%s pid:%d", __FUNCTION__, clicon_int2str(proc_operation_map, op), pe->pe_pid);
pe->pe_op = PROC_OP_NONE; pe->pe_op = PROC_OP_NONE;