* Reverted blocked signal behavior introduced in 5.0.

* Introduced a delay before making process start/stop/restart processes for race conditions when configuring eg restconf
* For restconf `CLICON_BACKEND_RESTCONF_PROCESS`, restart restconf if restconf is edited.
This commit is contained in:
Olof hagsand 2021-03-02 12:24:07 +01:00
parent 46ebc12bd5
commit b2f9c59a34
14 changed files with 304 additions and 122 deletions

View file

@ -86,8 +86,12 @@ static struct event_data *ee_timers = NULL;
/* Set if element in ee is deleted (clixon_event_unreg_fd). Check in ee loops */
static int _ee_unreg = 0;
/* If set (eg by signal handler) exit select loop on next run and return 0 */
static int _clicon_exit = 0;
/* If set (eg by signal handler) ignore EINTR and continue select loop */
static int _clicon_sig_ignore = 0;
/*! For signal handlers: instead of doing exit, set a global variable to exit
* Status is then checked in event_loop.
* Note it maybe would be better to do use on a handle basis, but a signal
@ -117,6 +121,19 @@ clicon_exit_get(void)
return _clicon_exit;
}
int
clicon_sig_ignore_set(int val)
{
_clicon_sig_ignore = val;
return 0;
}
int
clicon_sig_ignore_get(void)
{
return _clicon_sig_ignore;
}
/*! Register a callback function to be called on input on a file descriptor.
*
* @param[in] fd File descriptor
@ -320,18 +337,26 @@ clixon_event_loop(void)
if (clicon_exit_get())
break;
if (n == -1) {
/* Signals either set clixon_exit, then the function returns 0
* Typically for set_signal() of SIGTERM,SIGINT, etc
* Other signals are ignored, and the select is rerun, eg SIGCHLD
*/
if (errno == EINTR){
/* Signals are checked and are in three classes:
* (1) Signals that exit gracefully, the function returns 0
* Must be registered such as by set_signal() of SIGTERM,SIGINT, etc with a handler that calls
* clicon_exit_set().
* (2) Signals that are ignored, and the select is rerun, eg SIGCHLD if handler calls clicon_sig_ignore()
* New select loop is called
* (3) Other signals result in an error and return -1.
*/
clicon_debug(1, "%s select: %s", __FUNCTION__, strerror(errno));
if (clicon_exit_get()){
clicon_err(OE_EVENTS, errno, "select");
retval = 0;
}
else
else if (clicon_sig_ignore_get()){
clicon_sig_ignore_set(0);
continue;
}
else
clicon_err(OE_EVENTS, errno, "select");
}
else
clicon_err(OE_EVENTS, errno, "select");