summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-worker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev/udev-worker.c')
-rw-r--r--src/udev/udev-worker.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/udev/udev-worker.c b/src/udev/udev-worker.c
index 53722b2..97c5679 100644
--- a/src/udev/udev-worker.c
+++ b/src/udev/udev-worker.c
@@ -138,11 +138,7 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
if (!device_for_action(dev, SD_DEVICE_ADD))
return 0;
- r = sd_device_get_subsystem(dev, &val);
- if (r < 0)
- return log_device_debug_errno(dev, r, "Failed to get subsystem: %m");
-
- if (!streq(val, "block"))
+ if (!device_in_subsystem(dev, "block"))
return 0;
r = sd_device_get_sysname(dev, &val);
@@ -176,7 +172,7 @@ static int worker_process_device(UdevWorker *worker, sd_device *dev) {
log_device_uevent(dev, "Processing device");
- udev_event = udev_event_new(dev, worker->exec_delay_usec, worker->rtnl, worker->log_level);
+ udev_event = udev_event_new(dev, worker, EVENT_UDEV_WORKER);
if (!udev_event)
return -ENOMEM;
@@ -194,18 +190,17 @@ static int worker_process_device(UdevWorker *worker, sd_device *dev) {
if (worker->blockdev_read_only)
(void) worker_mark_block_device_read_only(dev);
+ /* Disable watch during event processing. */
+ r = udev_watch_end(worker->inotify_fd, dev);
+ if (r < 0)
+ log_device_warning_errno(dev, r, "Failed to remove inotify watch, ignoring: %m");
+
/* apply rules, create node, symlinks */
- r = udev_event_execute_rules(
- udev_event,
- worker->inotify_fd,
- worker->timeout_usec,
- worker->timeout_signal,
- worker->properties,
- worker->rules);
+ r = udev_event_execute_rules(udev_event, worker->rules);
if (r < 0)
return r;
- udev_event_execute_run(udev_event, worker->timeout_usec, worker->timeout_signal);
+ udev_event_execute_run(udev_event);
if (!worker->rtnl)
/* in case rtnl was initialized */
@@ -217,6 +212,15 @@ static int worker_process_device(UdevWorker *worker, sd_device *dev) {
log_device_warning_errno(dev, r, "Failed to add inotify watch, ignoring: %m");
}
+ /* Finalize database. */
+ r = device_add_property(dev, "ID_PROCESSING", NULL);
+ if (r < 0)
+ return log_device_warning_errno(dev, r, "Failed to remove 'ID_PROCESSING' property: %m");
+
+ r = device_update_db(dev);
+ if (r < 0)
+ return log_device_warning_errno(dev, r, "Failed to update database under /run/udev/data/: %m");
+
log_device_uevent(dev, "Device processed");
return 0;
}
@@ -245,6 +249,7 @@ void udev_broadcast_result(sd_device_monitor *monitor, sd_device *dev, EventResu
break;
}
case EVENT_RESULT_EXIT_STATUS_BASE ... EVENT_RESULT_EXIT_STATUS_MAX:
+ assert(result != EVENT_RESULT_EXIT_STATUS_BASE);
(void) device_add_propertyf(dev, "UDEV_WORKER_EXIT_STATUS", "%i", result - EVENT_RESULT_EXIT_STATUS_BASE);
break;
@@ -318,8 +323,6 @@ int udev_worker_main(UdevWorker *worker, sd_device *dev) {
DEVICE_TRACE_POINT(worker_spawned, dev, getpid_cached());
- assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, -1) >= 0);
-
/* Reset OOM score, we only protect the main daemon. */
r = set_oom_score_adjust(0);
if (r < 0)
@@ -329,7 +332,7 @@ int udev_worker_main(UdevWorker *worker, sd_device *dev) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- r = sd_event_add_signal(worker->event, NULL, SIGTERM, NULL, NULL);
+ r = sd_event_add_signal(worker->event, NULL, SIGTERM | SD_EVENT_SIGNAL_PROCMASK, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Failed to set SIGTERM event: %m");