systemd: add patch to avoid spurious stalling during reboots

This modifies the behavior of the sd-resolve libsystemd component to prevent
the system from freezing whenever a service that uses said component is
stopped. Even though this doesn't free the terminated thread's resources
properly, this procedure only gets executed during the final moments of a
service's process before it exits, so resource leaks aren't an issue.

https://jira.digi.com/browse/DEL-6523

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2019-03-28 18:08:19 +01:00
parent 47f88d1d24
commit df3858f473
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 28 Mar 2019 17:40:00 +0100
Subject: [PATCH] sd-resolve: forcefully cancel worker threads during
resolve_free
For services that use sd-resolve, such as timesyncd, this prevents the system
from stalling whenever the service stops while a worker thread is busy calling
getaddrinfo().
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
src/libsystemd/sd-resolve/sd-resolve.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index a189f14..571604c 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -577,8 +577,10 @@ static void resolve_free(sd_resolve *resolve) {
/* Now terminate them and wait until they are gone.
If we get an error than most likely the thread already exited. */
- for (i = 0; i < resolve->n_valid_workers; i++)
+ for (i = 0; i < resolve->n_valid_workers; i++) {
+ pthread_cancel(resolve->workers[i]);
(void) pthread_join(resolve->workers[i], NULL);
+ }
/* Close all communication channels */
close_many(resolve->fds, _FD_MAX);

View File

@ -1,6 +1,9 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI += "file://0001-udev-use-the-usual-set-of-load-paths-for-udev-rules.patch"
SRC_URI += " \
file://0001-udev-use-the-usual-set-of-load-paths-for-udev-rules.patch \
file://0002-sd-resolve-forcefully-cancel-worker-threads-during-r.patch \
"
#FIX-it: Workaround as missing ending slash in FIRMWARE_PATH [YOCIMX-2831]
EXTRA_OEMESON_remove = "-Dfirmware-path=${nonarch_base_libdir}/firmware "