Handle event loop watcher failure modes

When alibuEv event watcher callback has `UEV_ERROR` in the events mask
we must handle the error.  Unfortunately, in most cases there is not
much we can do but ignore it or log the error.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-11-12 11:18:12 +01:00
1 parent 168da2a5c6
commit 6826d7ee3f
4 files changed
+52 -1

No files matched your search

+5
View File
@@ -173,6 +173,11 @@ static void cb(uev_t *w, void *arg, int events)
int sd, lvl;
struct init_request rq;
if (UEV_ERROR == events) {
_e("Unrecoverable error on API socket");
return;
}
sd = accept(w->fd, NULL, NULL);
if (sd < 0) {
_pe("Failed serving API request");
+6 -1
View File
@@ -142,7 +142,12 @@ static void socket_cb(uev_t *w, void *arg, int events)
svc_t *svc = (svc_t *)arg, *task;
int stdin;
_d("Got event on %s socket ...", svc->cmd);
_d("%s: Got socket event ...", svc->cmd);
if (UEV_ERROR == events) {
logit(LOG_INFO, "%s: Socket error, aborting: %m", svc->cmd);
return;
}
stdin = get_stdin(svc);
if (stdin < 0) {
logit(LOG_CRIT, "%s: Unable to accept incoming connection", svc->cmd);
+1
View File
@@ -82,6 +82,7 @@ static void service_timeout_cb(uev_t *w, void *arg, int events)
{
svc_t *svc = arg;
/* Ignore any UEV_ERROR, we're a one-shot cb so just run it. */
svc->timer_cb(svc);
}
+40
View File
@@ -224,6 +224,11 @@ void do_shutdown(shutop_t op)
static void sighup_cb(uev_t *w, void *arg, int events)
{
_d("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
/* INIT_CMD_RELOAD: 'init q', 'initctl reload', and SIGHUP */
service_reload_dynamic();
}
@@ -234,6 +239,11 @@ static void sighup_cb(uev_t *w, void *arg, int events)
static void sigint_cb(uev_t *w, void *arg, int events)
{
_d("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
halt = SHUT_REBOOT;
service_runlevel(6);
}
@@ -244,6 +254,11 @@ static void sigint_cb(uev_t *w, void *arg, int events)
static void sigusr1_cb(uev_t *w, void *arg, int events)
{
_d("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
halt = SHUT_HALT;
service_runlevel(0);
}
@@ -254,6 +269,11 @@ static void sigusr1_cb(uev_t *w, void *arg, int events)
static void sigusr2_cb(uev_t *w, void *arg, int events)
{
_d("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
halt = SHUT_OFF;
service_runlevel(0);
}
@@ -264,6 +284,11 @@ static void sigusr2_cb(uev_t *w, void *arg, int events)
static void sigterm_cb(uev_t *w, void *arg, int events)
{
_d("...");
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
halt = SHUT_REBOOT;
service_runlevel(6);
}
@@ -275,6 +300,11 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
{
pid_t pid;
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
/* Reap all the children! */
do {
pid = waitpid(-1, NULL, WNOHANG);
@@ -290,6 +320,11 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
*/
static void sigstop_cb(uev_t *w, void *arg, int events)
{
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
touch(SYNC_STOPPED);
stopped++;
}
@@ -299,6 +334,11 @@ static void sigstop_cb(uev_t *w, void *arg, int events)
*/
static void sigcont_cb(uev_t *w, void *arg, int events)
{
if (UEV_ERROR == events) {
_e("Unrecoverable error in signal watcher");
return;
}
stopped = 0;
erase(SYNC_STOPPED);
}