summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-11-27 11:16:12 +0100
committerGitHub <noreply@github.com>2019-11-27 11:16:12 +0100
commit403e4b47286548bfd4102159bfc0dcf2f306bc1b (patch)
tree5b6af372bb9d64989d727288f566db493dc6cce2
parentman/systemd.link: Add missing verb *be* (diff)
parentudevd: don't use monitor after manager_exit() (diff)
downloadsystemd-403e4b47286548bfd4102159bfc0dcf2f306bc1b.tar.xz
systemd-403e4b47286548bfd4102159bfc0dcf2f306bc1b.zip
Merge pull request #14160 from mwilck/fix-shutdown-hang
Fix shutdown hang caused by recent udev change
-rw-r--r--src/udev/udevd.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 2bb322796b..7678331897 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -293,8 +293,6 @@ static void manager_free(Manager *manager) {
if (!manager)
return;
- manager->monitor = sd_device_monitor_unref(manager->monitor);
-
udev_builtin_exit();
if (manager->pid == getpid_cached())
@@ -791,6 +789,8 @@ static void manager_exit(Manager *manager) {
manager->inotify_event = sd_event_source_unref(manager->inotify_event);
manager->fd_inotify = safe_close(manager->fd_inotify);
+ manager->monitor = sd_device_monitor_unref(manager->monitor);
+
/* discard queued events and kill workers */
event_queue_cleanup(manager, EVENT_QUEUED);
manager_kill_workers(manager);
@@ -1311,10 +1311,12 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
device_delete_db(worker->event->dev);
device_tag_index(worker->event->dev, NULL, false);
- /* forward kernel event without amending it */
- r = device_monitor_send_device(manager->monitor, NULL, worker->event->dev_kernel);
- if (r < 0)
- log_device_error_errno(worker->event->dev_kernel, r, "Failed to send back device to kernel: %m");
+ if (manager->monitor) {
+ /* forward kernel event without amending it */
+ r = device_monitor_send_device(manager->monitor, NULL, worker->event->dev_kernel);
+ if (r < 0)
+ log_device_error_errno(worker->event->dev_kernel, r, "Failed to send back device to kernel: %m");
+ }
}
worker_free(worker);