config: Use NotifyFd interface for udev
This uses the NotifyFd interface to monitor the udev file descriptor rather than adding another block/wakeup handler Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
bf920b2390
commit
8c8f3567fe
|
@ -332,16 +332,11 @@ device_removed(struct udev_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wakeup_handler(void *data, int err, void *read_mask)
|
socket_handler(int fd, int ready, void *data)
|
||||||
{
|
{
|
||||||
int udev_fd = udev_monitor_get_fd(udev_monitor);
|
|
||||||
struct udev_device *udev_device;
|
struct udev_device *udev_device;
|
||||||
const char *action;
|
const char *action;
|
||||||
|
|
||||||
if (err < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (FD_ISSET(udev_fd, (fd_set *) read_mask)) {
|
|
||||||
udev_device = udev_monitor_receive_device(udev_monitor);
|
udev_device = udev_monitor_receive_device(udev_monitor);
|
||||||
if (!udev_device)
|
if (!udev_device)
|
||||||
return;
|
return;
|
||||||
|
@ -361,12 +356,6 @@ wakeup_handler(void *data, int err, void *read_mask)
|
||||||
device_removed(udev_device);
|
device_removed(udev_device);
|
||||||
}
|
}
|
||||||
udev_device_unref(udev_device);
|
udev_device_unref(udev_device);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
block_handler(void *data, struct timeval **tv, void *read_mask)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -441,8 +430,7 @@ config_udev_init(void)
|
||||||
}
|
}
|
||||||
udev_enumerate_unref(enumerate);
|
udev_enumerate_unref(enumerate);
|
||||||
|
|
||||||
RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
|
SetNotifyFd(udev_monitor_get_fd(udev_monitor), socket_handler, X_NOTIFY_READ, NULL);
|
||||||
AddGeneralSocket(udev_monitor_get_fd(udev_monitor));
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -457,8 +445,7 @@ config_udev_fini(void)
|
||||||
|
|
||||||
udev = udev_monitor_get_udev(udev_monitor);
|
udev = udev_monitor_get_udev(udev_monitor);
|
||||||
|
|
||||||
RemoveGeneralSocket(udev_monitor_get_fd(udev_monitor));
|
RemoveNotifyFd(udev_monitor_get_fd(udev_monitor));
|
||||||
RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
|
|
||||||
udev_monitor_unref(udev_monitor);
|
udev_monitor_unref(udev_monitor);
|
||||||
udev_monitor = NULL;
|
udev_monitor = NULL;
|
||||||
udev_unref(udev);
|
udev_unref(udev);
|
||||||
|
|
Loading…
Reference in New Issue