diff --git a/src/api.c b/src/api.c index 87553019..04b9f82f 100644 --- a/src/api.c +++ b/src/api.c @@ -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"); diff --git a/src/inetd.c b/src/inetd.c index e476405b..e3c0dd31 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -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); diff --git a/src/service.c b/src/service.c index e34eed25..06605c5d 100644 --- a/src/service.c +++ b/src/service.c @@ -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); } diff --git a/src/sig.c b/src/sig.c index 79ace6c4..2c5c5917 100644 --- a/src/sig.c +++ b/src/sig.c @@ -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); }