return r;
}
+static void
+dev_handle_data(__unused void *arg)
+{
+
+ if (dev->handle_device() == -1) {
+ /* XXX: an error occured. should we restart dev? */
+ }
+}
+
int
dev_start(const char *plugin)
{
fd = dev_start1(plugin);
if (fd != -1) {
- if (eloop_event_add(fd, dev->handle_data, NULL) == -1) {
+ if (eloop_event_add(fd, dev_handle_data, NULL) == -1) {
syslog(LOG_ERR, "%s: eloop_event_add: %m", __func__);
dev_stop();
return -1;
const char *name;
int (*initialized)(const char *);
int (*listening)(void);
- void (*handle_data)(void *);
+ int (*handle_device)(void);
int (*start)(void);
void (*stop)(void);
};
return r;
}
-static void
-udev_handle_data(__unused void *arg)
+static int
+udev_handle_device(void)
{
struct udev_device *device;
const char *subsystem, *ifname, *action;
device = udev_monitor_receive_device(monitor);
if (device == NULL) {
- syslog(LOG_DEBUG, "libudev: received NULL device");
- return;
+ syslog(LOG_ERR, "libudev: received NULL device");
+ return -1;
}
subsystem = udev_device_get_subsystem(device);
}
udev_device_unref(device);
+ return 1;
}
static void
dev->name = udev_name;
dev->initialized = udev_initialized;
dev->listening = udev_listening;
- dev->handle_data = udev_handle_data;
+ dev->handle_device = udev_handle_device;
dev->stop = udev_stop;
dev->start = udev_start;