mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-23 18:14:09 +08:00
Allow dev to recieve errors from managers handle_device.
This commit is contained in:
parent
4b21a1f7c9
commit
36d293b12a
11
dev.c
11
dev.c
@ -143,13 +143,22 @@ dev_start1(const char *plugin)
|
||||
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;
|
||||
|
2
dev.h
2
dev.h
@ -32,7 +32,7 @@ struct dev {
|
||||
const char *name;
|
||||
int (*initialized)(const char *);
|
||||
int (*listening)(void);
|
||||
void (*handle_data)(void *);
|
||||
int (*handle_device)(void);
|
||||
int (*start)(void);
|
||||
void (*stop)(void);
|
||||
};
|
||||
|
11
dev/udev.c
11
dev/udev.c
@ -72,16 +72,16 @@ udev_initialized(const char *ifname)
|
||||
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);
|
||||
@ -98,6 +98,7 @@ udev_handle_data(__unused void *arg)
|
||||
}
|
||||
|
||||
udev_device_unref(device);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -168,7 +169,7 @@ dev_init(struct dev *dev, const struct dev_dhcpcd *dev_dhcpcd)
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user