From 178596166072dfb4c239f0b22ff201f860e6c139 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 17 Apr 2025 04:12:27 +0900 Subject: [PATCH 1/2] udev: re-add unintentionally dropped error log Follow-up for 9b6bf4e10e7464784609989c77b6a6fb1d38066e. --- src/udev/udev-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c index d35100198b..234deb1378 100644 --- a/src/udev/udev-manager.c +++ b/src/udev/udev-manager.c @@ -1166,7 +1166,7 @@ static int manager_listen_fds(Manager *manager) { int n = sd_listen_fds_with_names(/* unset_environment = */ true, &names); if (n < 0) - return n; + return log_error_errno(n, "Failed to listen on fds: %m"); for (int i = 0; i < n; i++) { int fd = SD_LISTEN_FDS_START + i; From f6a2a9ba93c5df37a197cf03552b7f3577341191 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 18 Apr 2025 09:00:35 +0900 Subject: [PATCH 2/2] daemon-util: remove existing fds with the same name from fdstore Currently, all use cases of notify_push_fd()/notify_push_fdf() assume that the name of each fd in the fdstore is unique. For safety, let's remove the existing fds before pushing a new one to avoid multiple fds with the same name stored in the fdstore. --- src/shared/daemon-util.c | 3 +++ src/udev/udev-config.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/daemon-util.c b/src/shared/daemon-util.c index e83ca8f663..85d9433626 100644 --- a/src/shared/daemon-util.c +++ b/src/shared/daemon-util.c @@ -56,6 +56,9 @@ int notify_push_fd(int fd, const char *name) { if (!state) return -ENOMEM; + /* Remove existing fds with the same name in fdstore. */ + (void) notify_remove_fd_warn(name); + return sd_pid_notify_with_fds(0, /* unset_environment = */ false, state, &fd, 1); } diff --git a/src/udev/udev-config.c b/src/udev/udev-config.c index 52855145da..ef0ee0abd6 100644 --- a/src/udev/udev-config.c +++ b/src/udev/udev-config.c @@ -553,9 +553,6 @@ int manager_serialize_config(Manager *manager) { if (r < 0) return log_warning_errno(r, "Failed to finalize serialization file: %m"); - /* Remove the previous serialization to make it replaced with the new one. */ - (void) notify_remove_fd_warn("config-serialization"); - r = notify_push_fd(fileno(f), "config-serialization"); if (r < 0) return log_warning_errno(r, "Failed to push serialization fd to service manager: %m");