mirror of
https://github.com/termux-pacman/termux-packages.git
synced 2026-01-28 13:42:37 +00:00
81 lines
2.8 KiB
Diff
81 lines
2.8 KiB
Diff
diff --git a/src/bio.c b/src/bio.c
|
|
index 295850046..2a2185c32 100644
|
|
--- a/src/bio.c
|
|
+++ b/src/bio.c
|
|
@@ -399,7 +399,11 @@ void bioKillThreads(void) {
|
|
|
|
for (j = 0; j < BIO_WORKER_NUM; j++) {
|
|
if (bio_threads[j] == pthread_self()) continue;
|
|
+#ifndef __ANDROID__
|
|
if (bio_threads[j] && pthread_cancel(bio_threads[j]) == 0) {
|
|
+#else
|
|
+ if (bio_threads[j] && pthread_kill(bio_threads[j], SIGUSR2) == 0) {
|
|
+#endif
|
|
if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
|
|
serverLog(LL_WARNING,
|
|
"Bio worker thread #%lu can not be joined: %s",
|
|
diff --git a/src/debug.c b/src/debug.c
|
|
index 4ff7da7e7..63405a2b5 100644
|
|
--- a/src/debug.c
|
|
+++ b/src/debug.c
|
|
@@ -2283,7 +2283,11 @@ int memtest_test_linux_anonymous_maps(void) {
|
|
|
|
static void killMainThread(void) {
|
|
int err;
|
|
+#ifndef __ANDROID__
|
|
if (pthread_self() != server.main_thread_id && pthread_cancel(server.main_thread_id) == 0) {
|
|
+#else
|
|
+ if (pthread_self() != server.main_thread_id && pthread_kill(server.main_thread_id, SIGUSR2) == 0) {
|
|
+#endif
|
|
if ((err = pthread_join(server.main_thread_id,NULL)) != 0) {
|
|
serverLog(LL_WARNING, "main thread can not be joined: %s", strerror(err));
|
|
} else {
|
|
diff --git a/src/iothread.c b/src/iothread.c
|
|
index 27d533923..ffe98fcfd 100644
|
|
--- a/src/iothread.c
|
|
+++ b/src/iothread.c
|
|
@@ -796,7 +796,11 @@ void killIOThreads(void) {
|
|
int err, j;
|
|
for (j = 1; j < server.io_threads_num; j++) {
|
|
if (IOThreads[j].tid == pthread_self()) continue;
|
|
+#ifndef __ANDROID__
|
|
if (IOThreads[j].tid && pthread_cancel(IOThreads[j].tid) == 0) {
|
|
+#else
|
|
+ if (IOThreads[j].tid && pthread_kill(IOThreads[j].tid, SIGUSR2) == 0) {
|
|
+#endif
|
|
if ((err = pthread_join(IOThreads[j].tid,NULL)) != 0) {
|
|
serverLog(LL_WARNING,
|
|
"IO thread(tid:%lu) can not be joined: %s",
|
|
diff --git a/src/server.c b/src/server.c
|
|
index 41607356d..501cb3833 100644
|
|
--- a/src/server.c
|
|
+++ b/src/server.c
|
|
@@ -2756,12 +2756,27 @@ void resetServerStats(void) {
|
|
lazyfreeResetStats();
|
|
}
|
|
|
|
+#ifdef __ANDROID__
|
|
+static void threadSignalHandler(int signum) {
|
|
+ pthread_exit(0);
|
|
+}
|
|
+#endif
|
|
+
|
|
/* Make the thread killable at any time, so that kill threads functions
|
|
* can work reliably (default cancelability type is PTHREAD_CANCEL_DEFERRED).
|
|
* Needed for pthread_cancel used by the fast memory test used by the crash report. */
|
|
void makeThreadKillable(void) {
|
|
+#ifndef __ANDROID__
|
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
|
+#else
|
|
+ struct sigaction actions;
|
|
+ memset(&actions, 0, sizeof(actions));
|
|
+ sigemptyset(&actions.sa_mask);
|
|
+ actions.sa_flags = 0;
|
|
+ actions.sa_handler = threadSignalHandler;
|
|
+ sigaction(SIGUSR2, &actions, NULL);
|
|
+#endif
|
|
}
|
|
|
|
void initServer(void) {
|