1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

udevd: explicitly update queue file before answering to ping

This avoids updating the flag files twice for every loop, and also removes another dependency
in the main-loop, so we are freer to reshufle it as we want.
This commit is contained in:
Tom Gundersen 2015-05-12 16:55:29 +02:00
parent a8389097c0
commit 799a108c07

View File

@ -696,6 +696,20 @@ static int on_uevent(sd_event_source *s, int fd, uint32_t revents, void *userdat
return 1;
}
static void event_queue_update(void) {
int r;
if (!udev_list_node_is_empty(&event_list)) {
r = touch("/run/udev/queue");
if (r < 0)
log_warning_errno(r, "could not touch /run/udev/queue: %m");
} else {
r = unlink("/run/udev/queue");
if (r < 0 && errno != ENOENT)
log_warning("could not unlink /run/udev/queue: %m");
}
}
/* receive the udevd message from userspace */
static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
struct udev_ctrl *uctrl = userdata;
@ -769,8 +783,13 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userd
arg_children_max = i;
}
if (udev_ctrl_get_ping(ctrl_msg) > 0)
if (udev_ctrl_get_ping(ctrl_msg) > 0) {
log_debug("udevd message (SYNC) received");
/* tell settle that we are busy or idle, this needs to be before the
* PING handling
*/
event_queue_update();
}
if (udev_ctrl_get_exit(ctrl_msg) > 0) {
log_debug("udevd message (EXIT) received");
@ -987,20 +1006,6 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
return 1;
}
static void event_queue_update(void) {
int r;
if (!udev_list_node_is_empty(&event_list)) {
r = touch("/run/udev/queue");
if (r < 0)
log_warning_errno(r, "could not touch /run/udev/queue: %m");
} else {
r = unlink("/run/udev/queue");
if (r < 0 && errno != ENOENT)
log_warning("could not unlink /run/udev/queue: %m");
}
}
static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink) {
int ctrl = -1, netlink = -1;
int fd, n;
@ -1575,11 +1580,6 @@ int main(int argc, char *argv[]) {
if (is_inotify)
on_inotify(NULL, fd_inotify, 0, udev);
/* tell settle that we are busy or idle, this needs to be before the
* PING handling
*/
event_queue_update();
/*
* This needs to be after the inotify handling, to make sure,
* that the ping is send back after the possibly generated