|
| 1 | +diff -ur orig/src/lib/eina/eina_debug_timer.c mod/src/lib/eina/eina_debug_timer.c |
| 2 | +--- orig/src/lib/eina/eina_debug_timer.c 2025-01-11 21:08:11.000000000 +0100 |
| 3 | ++++ mod/src/lib/eina/eina_debug_timer.c 2025-01-21 21:18:36.155542280 +0100 |
| 4 | +@@ -105,7 +105,7 @@ |
| 5 | + while (1) |
| 6 | + { |
| 7 | + int timeout = -1; //in milliseconds |
| 8 | +- pthread_testcancel(); |
| 9 | ++ //pthread_testcancel(); |
| 10 | + eina_spinlock_take(&_lock); |
| 11 | + if (_timers) |
| 12 | + { |
| 13 | +@@ -115,7 +115,7 @@ |
| 14 | + eina_spinlock_release(&_lock); |
| 15 | + |
| 16 | + ret = epoll_wait(epfd, events, MAX_EVENTS, timeout); |
| 17 | +- pthread_testcancel(); |
| 18 | ++ //pthread_testcancel(); |
| 19 | + |
| 20 | + /* Some timer has been add/removed or we need to exit */ |
| 21 | + if (ret) |
| 22 | +@@ -228,7 +228,7 @@ |
| 23 | + close(pipeToThread[0]); |
| 24 | + close(pipeToThread[1]); |
| 25 | + if (_thread_runs) |
| 26 | +- pthread_cancel(_thread); |
| 27 | ++ pthread_kill(_thread, SIGUSR2); |
| 28 | + _thread_runs = 0; |
| 29 | + eina_spinlock_release(&_lock); |
| 30 | + eina_spinlock_free(&_lock); |
| 31 | +diff -ur orig/src/lib/eina/eina_thread_posix.c mod/src/lib/eina/eina_thread_posix.c |
| 32 | +--- orig/src/lib/eina/eina_thread_posix.c 2025-01-11 21:08:11.000000000 +0100 |
| 33 | ++++ mod/src/lib/eina/eina_thread_posix.c 2025-01-21 21:19:56.666136007 +0100 |
| 34 | +@@ -56,7 +56,16 @@ |
| 35 | + |
| 36 | + #define RTNICENESS 1 |
| 37 | + #define NICENESS 5 |
| 38 | ++#define PTHREAD_CANCELED ((void *)-1) |
| 39 | ++#define true 1 |
| 40 | ++#define false 0 |
| 41 | + |
| 42 | ++#ifdef __ANDROID__ |
| 43 | ++static void thread_signal_handler(int signum) |
| 44 | ++{ |
| 45 | ++ pthread_exit(0); |
| 46 | ++} |
| 47 | ++#endif |
| 48 | + |
| 49 | + static inline void * |
| 50 | + _eina_thread_join(Eina_Thread t) |
| 51 | +@@ -278,15 +287,16 @@ |
| 52 | + eina_thread_cancel(Eina_Thread t) |
| 53 | + { |
| 54 | + if (!t) return EINA_FALSE; |
| 55 | +- return pthread_cancel((pthread_t)t) == 0; |
| 56 | ++ return pthread_kill((pthread_t)t, SIGTERM) == 0; |
| 57 | + } |
| 58 | + |
| 59 | +-EINA_API Eina_Bool |
| 60 | +-eina_thread_cancellable_set(Eina_Bool cancellable, Eina_Bool *was_cancellable) |
| 61 | ++//EINA_API Eina_Bool |
| 62 | ++Eina_Bool eina_thread_cancellable_set(Eina_Bool cancellable, Eina_Bool *was_cancellable) |
| 63 | + { |
| 64 | +- int state = cancellable ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE; |
| 65 | +- int old = 0; |
| 66 | +- int r; |
| 67 | ++#ifndef __ANDROID__ |
| 68 | ++ int state = cancellable ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE; |
| 69 | ++ int old = 0; |
| 70 | ++ int r; |
| 71 | + |
| 72 | + /* enforce deferred in case users changed to asynchronous themselves */ |
| 73 | + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old); |
| 74 | +@@ -296,12 +306,36 @@ |
| 75 | + *was_cancellable = (old == PTHREAD_CANCEL_ENABLE); |
| 76 | + |
| 77 | + return r == 0; |
| 78 | ++#else |
| 79 | ++ static int old_cancellable = 0; |
| 80 | ++ struct sigaction actions; |
| 81 | ++ |
| 82 | ++ if (was_cancellable) |
| 83 | ++ *was_cancellable = old_cancellable; |
| 84 | ++ |
| 85 | ++ if (cancellable) { |
| 86 | ++ memset(&actions, 0, sizeof(actions)); |
| 87 | ++ sigemptyset(&actions.sa_mask); |
| 88 | ++ actions.sa_flags = 0; |
| 89 | ++ actions.sa_handler = thread_signal_handler; |
| 90 | ++ sigaction(SIGUSR2, &actions, NULL); |
| 91 | ++ old_cancellable = 1; |
| 92 | ++ } else { |
| 93 | ++ memset(&actions, 0, sizeof(actions)); |
| 94 | ++ sigemptyset(&actions.sa_mask); |
| 95 | ++ actions.sa_handler = SIG_IGN; |
| 96 | ++ sigaction(SIGUSR2, &actions, NULL); |
| 97 | ++ old_cancellable = 0; |
| 98 | ++ } |
| 99 | ++ |
| 100 | ++ return true; |
| 101 | ++#endif |
| 102 | + } |
| 103 | + |
| 104 | + EINA_API void |
| 105 | + eina_thread_cancel_checkpoint(void) |
| 106 | + { |
| 107 | +- pthread_testcancel(); |
| 108 | ++ //pthread_testcancel(); |
| 109 | + } |
| 110 | + |
| 111 | + EINA_API const void *EINA_THREAD_JOIN_CANCELED = PTHREAD_CANCELED; |
0 commit comments