Skip to content

Commit f6a2a9b

Browse files
committed
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.
1 parent 1785961 commit f6a2a9b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/shared/daemon-util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ int notify_push_fd(int fd, const char *name) {
5656
if (!state)
5757
return -ENOMEM;
5858

59+
/* Remove existing fds with the same name in fdstore. */
60+
(void) notify_remove_fd_warn(name);
61+
5962
return sd_pid_notify_with_fds(0, /* unset_environment = */ false, state, &fd, 1);
6063
}
6164

src/udev/udev-config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,6 @@ int manager_serialize_config(Manager *manager) {
553553
if (r < 0)
554554
return log_warning_errno(r, "Failed to finalize serialization file: %m");
555555

556-
/* Remove the previous serialization to make it replaced with the new one. */
557-
(void) notify_remove_fd_warn("config-serialization");
558-
559556
r = notify_push_fd(fileno(f), "config-serialization");
560557
if (r < 0)
561558
return log_warning_errno(r, "Failed to push serialization fd to service manager: %m");

0 commit comments

Comments
 (0)