summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-12 16:55:29 +0200
committerTom Gundersen <teg@jklm.no>2015-05-12 17:06:21 +0200
commit799a108c074bb3d6b4b44a9f2b69342cd60bb137 (patch)
tree853cae88cfe37d5867d9842cc4a910be1c056984 /src
parenta8389097c0cd91720424b25ee5c6825b4f69cb6a (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/udev/udevd.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 8528f7147b..e558098ef0 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -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