From: Lennart Poettering Date: Thu, 22 Jun 2023 10:04:46 +0000 (+0200) Subject: async: drop the now unused asynchronous_job() X-Git-Tag: v254-rc1~133^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=78b680f99bc23f8e55d3a0be7a58c0d8cda3959d;p=thirdparty%2Fsystemd.git async: drop the now unused asynchronous_job() --- diff --git a/src/shared/async.c b/src/shared/async.c index a98f31d3b85..cb5e179cdfa 100644 --- a/src/shared/async.c +++ b/src/shared/async.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include #include #include @@ -15,52 +14,6 @@ #include "process-util.h" #include "signal-util.h" -int asynchronous_job(void* (*func)(void *p), void *arg) { - sigset_t ss, saved_ss; - pthread_attr_t a; - pthread_t t; - int r, k; - - /* It kinda sucks that we have to resort to threads to implement an asynchronous close(), but well, such is - * life. */ - - r = pthread_attr_init(&a); - if (r > 0) - return -r; - - r = pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED); - if (r > 0) { - r = -r; - goto finish; - } - - assert_se(sigfillset(&ss) >= 0); - - /* Block all signals before forking off the thread, so that the new thread is started with all signals - * blocked. This way the existence of the new thread won't affect signal handling in other threads. */ - - r = pthread_sigmask(SIG_BLOCK, &ss, &saved_ss); - if (r > 0) { - r = -r; - goto finish; - } - - r = pthread_create(&t, &a, func, arg); - - k = pthread_sigmask(SIG_SETMASK, &saved_ss, NULL); - - if (r > 0) - r = -r; - else if (k > 0) - r = -k; - else - r = 0; - -finish: - pthread_attr_destroy(&a); - return r; -} - int asynchronous_sync(pid_t *ret_pid) { int r; diff --git a/src/shared/async.h b/src/shared/async.h index 2c7def993d2..71d044dd618 100644 --- a/src/shared/async.h +++ b/src/shared/async.h @@ -6,8 +6,6 @@ #include "macro.h" #include "rm-rf.h" -int asynchronous_job(void* (*func)(void *p), void *arg); - int asynchronous_sync(pid_t *ret_pid); int asynchronous_close(int fd); int asynchronous_rm_rf(const char *p, RemoveFlags flags); diff --git a/src/test/test-async.c b/src/test/test-async.c index 02028ce323f..64b94886ff3 100644 --- a/src/test/test-async.c +++ b/src/test/test-async.c @@ -13,19 +13,8 @@ #include "tests.h" #include "tmpfile-util.h" -static bool test_async = false; - -static void *async_func(void *arg) { - test_async = true; - - return NULL; -} - -TEST(test_async) { - assert_se(asynchronous_job(async_func, NULL) >= 0); +TEST(test_asynchronous_sync) { assert_se(asynchronous_sync(NULL) >= 0); - - assert_se(test_async); } TEST(asynchronous_close) {