summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--udev/udev-event.c2
-rw-r--r--udev/udev.h2
-rw-r--r--udev/udevadm-settle.c76
4 files changed, 27 insertions, 55 deletions
diff --git a/TODO b/TODO
index 34907d70d9..6bcec816c8 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
- - kill alarm()
-
- empty rules files and link to /dev/null are ok
- rename netif with ifindex not devname
diff --git a/udev/udev-event.c b/udev/udev-event.c
index 66bf62a246..e583cec292 100644
--- a/udev/udev-event.c
+++ b/udev/udev-event.c
@@ -49,7 +49,7 @@ struct udev_event *udev_event_new(struct udev_device *dev)
udev_list_init(&event->run_list);
event->fd_signal = -1;
event->birth_usec = now_usec();
- event->timeout_usec = UDEV_EVENT_TIMEOUT_SEC * 1000 * 1000;
+ event->timeout_usec = 120 * 1000 * 1000;
dbg(event->udev, "allocated event %p\n", event);
return event;
}
diff --git a/udev/udev.h b/udev/udev.h
index 0baca1fa43..16a029e486 100644
--- a/udev/udev.h
+++ b/udev/udev.h
@@ -26,8 +26,6 @@
#include "libudev.h"
#include "libudev-private.h"
-#define UDEV_EVENT_TIMEOUT_SEC 120
-
#define UDEV_CTRL_SOCK_PATH "@/org/kernel/udev/udevd"
struct udev_event {
diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c
index 38cb4f4968..afd4af5f4b 100644
--- a/udev/udevadm-settle.c
+++ b/udev/udevadm-settle.c
@@ -36,16 +36,6 @@
#include "udev.h"
-static volatile sig_atomic_t is_timeout;
-
-static void sig_handler(int signum)
-{
- switch (signum) {
- case SIGALRM:
- is_timeout = 1;
- }
-}
-
int udevadm_settle(struct udev *udev, int argc, char *argv[])
{
static const struct option options[] = {
@@ -57,29 +47,18 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
{ "help", no_argument, NULL, 'h' },
{}
};
+ unsigned long long start_usec = now_usec();
unsigned long long start = 0;
unsigned long long end = 0;
int quiet = 0;
const char *exists = NULL;
- int timeout = 180;
+ unsigned int timeout = 180;
struct pollfd pfd[1];
- struct sigaction act;
- sigset_t mask;
struct udev_queue *udev_queue = NULL;
- int rc = 1;
+ int rc = EXIT_FAILURE;
dbg(udev, "version %s\n", VERSION);
- /* set signal handlers */
- memset(&act, 0x00, sizeof(act));
- act.sa_handler = sig_handler;
- sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- sigaction(SIGALRM, &act, NULL);
- sigemptyset(&mask);
- sigaddset(&mask, SIGALRM);
- sigprocmask(SIG_UNBLOCK, &mask, NULL);
-
for (;;) {
int option;
int seconds;
@@ -121,11 +100,6 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
}
}
- if (timeout > 0)
- alarm(timeout);
- else
- is_timeout = 1;
-
udev_queue = udev_queue_new(udev);
if (udev_queue == NULL)
exit(2);
@@ -167,7 +141,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
if (udev_ctrl_send_ping(uctrl, timeout) < 0) {
info(udev, "no connection to daemon\n");
udev_ctrl_unref(uctrl);
- rc = 0;
+ rc = EXIT_SUCCESS;
goto out;
}
udev_ctrl_unref(uctrl);
@@ -188,30 +162,26 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
for (;;) {
struct stat statbuf;
- const struct timespec duration = { 1 , 0 };
if (exists != NULL && stat(exists, &statbuf) == 0) {
- rc = 0;
+ rc = EXIT_SUCCESS;
break;
}
if (start > 0) {
/* if asked for, wait for a specific sequence of events */
if (udev_queue_get_seqnum_sequence_is_finished(udev_queue, start, end) == 1) {
- rc = 0;
+ rc = EXIT_SUCCESS;
break;
}
} else {
/* exit if queue is empty */
if (udev_queue_get_queue_is_empty(udev_queue)) {
- rc = 0;
+ rc = EXIT_SUCCESS;
break;
}
}
- if (is_timeout)
- break;
-
if (pfd[0].fd >= 0) {
/* wake up once every second, or whenever the queue file gets gets closed */
if (poll(pfd, 1, 1000) > 0 && pfd[0].revents & POLLIN) {
@@ -220,21 +190,27 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
read(pfd[0].fd, buf, sizeof(buf));
}
} else {
- nanosleep(&duration, NULL);
+ sleep(1);
}
- }
- /* if we reached the timeout, print the list of remaining events */
- if (is_timeout) {
- struct udev_list_entry *list_entry;
-
- if (!quiet && udev_queue_get_queued_list_entry(udev_queue) != NULL) {
- info(udev, "timeout waiting for udev queue\n");
- printf("\nudevadm settle - timeout of %i seconds reached, the event queue contains:\n", timeout);
- udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue))
- printf(" %s (%s)\n",
- udev_list_entry_get_name(list_entry),
- udev_list_entry_get_value(list_entry));
+ if (timeout > 0) {
+ unsigned long long age_usec;
+
+ age_usec = now_usec() - start_usec;
+ if (age_usec / (1000 * 1000) >= timeout) {
+ struct udev_list_entry *list_entry;
+
+ if (!quiet && udev_queue_get_queued_list_entry(udev_queue) != NULL) {
+ info(udev, "timeout waiting for udev queue\n");
+ printf("\nudevadm settle - timeout of %i seconds reached, the event queue contains:\n", timeout);
+ udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue))
+ printf(" %s (%s)\n",
+ udev_list_entry_get_name(list_entry),
+ udev_list_entry_get_value(list_entry));
+ }
+
+ break;
+ }
}
}
out: