diff mbox series

Do not call sd_listen_fds() on cleanup

Message ID 20220714144706.2449544-1-sbabic@denx.de
State Accepted
Headers show
Series Do not call sd_listen_fds() on cleanup | expand

Commit Message

Stefano Babic July 14, 2022, 2:47 p.m. UTC
systemd creates the Unix Domain Sockets just once, but duplicates the
fds each time the daemon is started. According to systemd descritpion,
sd_listen_fds() returns the number of passed file descriptors when it is
called for the first time, successive calls return 0. It is then wrong
to call again sd_listen_fds() to decide if the socket must be removed,
because this call will always return 0 and will constraint SWUpdate to
remove the sockets. The effect is that a "systemctl restart swupdate"
will lead to a not working SWUpdate, because systemd will still pass the
file descriptors, but the socket files were removed by previous run.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Marco Braga <marco.braga@gmail.com>
---
 core/network_thread.c  | 2 +-
 core/progress_thread.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/core/network_thread.c b/core/network_thread.c
index 0e03188..61de5e0 100644
--- a/core/network_thread.c
+++ b/core/network_thread.c
@@ -313,7 +313,7 @@  static void empty_pipe(int fd)
 static void unlink_socket(void)
 {
 #ifdef CONFIG_SYSTEMD
-	if (sd_booted() && sd_listen_fds(0) > 0) {
+	if (sd_booted()) {
 		/*
 		 * There were socket fds handed-over by systemd,
 		 * so don't delete the socket file.
diff --git a/core/progress_thread.c b/core/progress_thread.c
index 7e21b3f..0d797cd 100644
--- a/core/progress_thread.c
+++ b/core/progress_thread.c
@@ -225,7 +225,7 @@  void swupdate_progress_done(const char *info)
 static void unlink_socket(void)
 {
 #ifdef CONFIG_SYSTEMD
-	if (sd_booted() && sd_listen_fds(0) > 0) {
+	if (sd_booted()) {
 		/*
 		 * There were socket fds handed-over by systemd,
 		 * so don't delete the socket file.