From 342e4b04a073220bd056273ab5c7fa79d7dc2304 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 29 Jul 2024 13:05:46 -0500 Subject: [PATCH 1/3] Add MaskTerminationSignalsInThread() from cf-reactor for sharing Ticket: CFE-4401 --- libutils/Makefile.am | 1 + libutils/signal_lib.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 libutils/signal_lib.h diff --git a/libutils/Makefile.am b/libutils/Makefile.am index 86d374ef..6015c6ac 100644 --- a/libutils/Makefile.am +++ b/libutils/Makefile.am @@ -70,6 +70,7 @@ libutils_la_SOURCES = \ sequence.c sequence.h \ string_sequence.c string_sequence.h \ set.c set.h \ + signal_lib.h \ stack.c stack.h \ threaded_stack.c threaded_stack.h \ statistics.c statistics.h \ diff --git a/libutils/signal_lib.h b/libutils/signal_lib.h new file mode 100644 index 00000000..35a1752e --- /dev/null +++ b/libutils/signal_lib.h @@ -0,0 +1,15 @@ +static inline void MaskTerminationSignalsInThread() +{ + /* Mask termination signals in a thread so that they always end up in the + * main thread. The function calls below should just always succeed and even + * if they didn't, there's nothing to do. */ + sigset_t th_sigset; + NDEBUG_UNUSED int ret = sigemptyset(&th_sigset); + assert(ret == 0); + ret = sigaddset(&th_sigset, SIGINT); + assert(ret == 0); + ret = sigaddset(&th_sigset, SIGTERM); + assert(ret == 0); + ret = pthread_sigmask(SIG_BLOCK, &th_sigset, NULL); + assert(ret == 0); +} From 29b69a7774edb28b33d1016f689fc7b4614b46b2 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 5 Aug 2024 14:35:21 -0500 Subject: [PATCH 2/3] On Android Termux fcntl file locks maybe arent supported at all. Make the debug message more specific about which file lock, wait or not, is failing. --- libutils/file_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libutils/file_lib.c b/libutils/file_lib.c index 271ae627..6db8b7f7 100644 --- a/libutils/file_lib.c +++ b/libutils/file_lib.c @@ -1953,7 +1953,7 @@ static int LockFD(int fd, short int lock_type, bool wait) { if (errno != EINTR) { - Log(LOG_LEVEL_DEBUG, "Failed to acquire file lock for FD %d: %s", + Log(LOG_LEVEL_DEBUG, "Failed to acquire file lock wait for FD %d: %s", fd, GetErrorStr()); return -1; } From e482ee87b5b392be20d29f771229e5c74ab32aed Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 11 Apr 2025 16:28:27 -0500 Subject: [PATCH 3/3] Fixed check for copy_file_range on Android AC_CHECK_FUNCS apparently doesn't take into account the __ANDROID_API__ level properly and so incorrectly determines that copy_file_range is available for termux at API 24 but copy_file_range is <= 34. Ticket: none Changelog: none --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6cac4631..c8b594b4 100644 --- a/configure.ac +++ b/configure.ac @@ -920,7 +920,7 @@ AC_CHECK_DECLS([FALLOC_FL_PUNCH_HOLE], [], [], [ ]) AC_CHECK_HEADERS([sys/sendfile.h]) AC_CHECK_FUNCS([sendfile]) -AC_CHECK_FUNCS([copy_file_range]) +AC_CHECK_DECL([copy_file_range]) dnl #######################################################################