mirror of
https://github.com/troglobit/finit.git
synced 2026-10-13 10:14:47 +00:00
Handle UEV_ERROR properly in all libuev callbacks
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -332,6 +332,11 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
int sd, lvl;
|
||||
svc_t *svc;
|
||||
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): api socket %d invalid.", __func__, w->fd);
|
||||
goto error;
|
||||
}
|
||||
|
||||
sd = accept(w->fd, NULL, NULL);
|
||||
if (sd < 0) {
|
||||
err(1, "Failed serving API request");
|
||||
@@ -578,8 +583,6 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
leave:
|
||||
close(sd);
|
||||
if (UEV_ERROR == events)
|
||||
goto error;
|
||||
return;
|
||||
error:
|
||||
api_exit();
|
||||
|
||||
@@ -259,6 +259,11 @@ static void cgroup_events_cb(uev_t *w, void *arg, int events)
|
||||
ssize_t sz;
|
||||
size_t off;
|
||||
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): inotify socket %d invalid.", __func__, w->fd);
|
||||
return;
|
||||
}
|
||||
|
||||
sz = read(w->fd, ev_buf, sizeof(ev_buf) - 1);
|
||||
if (sz <= 0) {
|
||||
err(1, "invalid inotify event");
|
||||
|
||||
@@ -1542,6 +1542,11 @@ static int conf_iwatch_read(int fd)
|
||||
|
||||
static void conf_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): iwatch socket %d invalid.", __func__, w->fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conf_iwatch_read(w->fd)) {
|
||||
err(1, "invalid inotify event");
|
||||
return;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "finit.h"
|
||||
#include "log.h"
|
||||
#include "schedule.h"
|
||||
|
||||
#define SC_INIT 0x494E4954 /* "INIT", see ascii(7) */
|
||||
@@ -35,6 +36,7 @@ static void cb(uev_t *w, void *arg, int events)
|
||||
struct wq *work = (struct wq *)arg;
|
||||
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): spurious problem with schedule work timer, restarting.", __func__);
|
||||
uev_timer_start(w);
|
||||
return;
|
||||
}
|
||||
|
||||
+8
-2
@@ -81,7 +81,12 @@ 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. */
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): spurious problem, svc %s.", __func__, svc_ident(svc, NULL, 0));
|
||||
uev_timer_start(w);
|
||||
return;
|
||||
}
|
||||
|
||||
if (svc->timer_cb)
|
||||
svc->timer_cb(svc);
|
||||
}
|
||||
@@ -2875,7 +2880,7 @@ void service_notify_cb(uev_t *w, void *arg, int events)
|
||||
ssize_t len;
|
||||
|
||||
if (UEV_ERROR == events) {
|
||||
warn("Spurious problem with %s notify callback, restarting.", svc_ident(svc, NULL, 0));
|
||||
dbg("Spurious problem with %s notify callback, restarting.", svc_ident(svc, NULL, 0));
|
||||
uev_io_start(w);
|
||||
return;
|
||||
}
|
||||
@@ -2933,6 +2938,7 @@ static void service_interval_cb(uev_t *w, void *arg, int events)
|
||||
|
||||
(void)arg;
|
||||
if (UEV_ERROR == events) {
|
||||
dbg("%s(): spurious problem, restarting.", __func__);
|
||||
uev_timer_start(w);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user