]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
async: drop the now unused asynchronous_job()
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Jun 2023 10:04:46 +0000 (12:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Jun 2023 08:05:16 +0000 (10:05 +0200)
src/shared/async.c
src/shared/async.h
src/test/test-async.c

index a98f31d3b85d30fc3e2243dd2753902c46af0a0b..cb5e179cdfafed85298c8578dacd43083d56494c 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <errno.h>
-#include <pthread.h>
 #include <stddef.h>
 #include <sys/prctl.h>
 #include <sys/wait.h>
 #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;
 
index 2c7def993d2c236f49097577b5e953e7587af3e6..71d044dd618787de25cc12de6c08fa540c4f1fcd 100644 (file)
@@ -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);
index 02028ce323ff1e11043723178e94e3559a4dac03..64b94886ff332d5d1bc85aa1d3cd4bb5aa07f901 100644 (file)
 #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) {