diff --git a/apps/backend/backend_plugin_restconf.c b/apps/backend/backend_plugin_restconf.c index 17af6d61..660fdfa6 100644 --- a/apps/backend/backend_plugin_restconf.c +++ b/apps/backend/backend_plugin_restconf.c @@ -192,7 +192,7 @@ restconf_pseudo_process_commit(clicon_handle h, xtarget = transaction_target(td); if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL) enabled++; - /* Toggle start/stop */ + /* Toggle start/stop if enable flag changed */ if ((cx = xpath_first(xtarget, NULL, "/restconf/enable")) != NULL && xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_ADD)){ if (clixon_process_operation(h, RESTCONF_PROCESS, @@ -203,12 +203,15 @@ restconf_pseudo_process_commit(clicon_handle h, if (transaction_dlen(xtarget) != 0 || transaction_alen(xtarget) != 0 || transaction_clen(xtarget) != 0){ - /* 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 - * cause the curl to fail. - */ - if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0, NULL) < 0) - goto done; + if ((cx = xpath_first(xtarget, NULL, "/restconf")) != NULL && + xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_ADD)){ + /* 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 + * cause the curl to fail. + */ + if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0, NULL) < 0) + goto done; + } } } retval = 0; diff --git a/lib/src/clixon_proc.c b/lib/src/clixon_proc.c index e173336f..3559623e 100644 --- a/lib/src/clixon_proc.c +++ b/lib/src/clixon_proc.c @@ -431,6 +431,7 @@ static int clixon_process_operation_one(const proc_operation op, const char *netns, char **argv, + const char *name, pid_t *pidp) { int retval = -1; @@ -441,7 +442,8 @@ clixon_process_operation_one(const proc_operation op, goto done; if (op == PROC_OP_STOP || op == PROC_OP_RESTART){ 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 */ run = 0; @@ -571,7 +573,7 @@ clixon_process_sched(int fd, pe = _proc_entry_list; do { 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; clicon_debug(1, "%s op:%s pid:%d", __FUNCTION__, clicon_int2str(proc_operation_map, op), pe->pe_pid); pe->pe_op = PROC_OP_NONE;