[PATCH v1] Use pthread_kill instead of pthread_cancel for compatibility

Kelvin Zhang zhangkelvin at google.com
Thu Oct 3 03:43:08 AEST 2024


pthread_kill is supported on more platforms. For example, android's
bionic libc does not have pthread_cancel. Since pthread_setcancelstate()
is not used in erofs-utils workqueue code, pthread_cancel has identical
behavior to pthread_kill, this switch should be safe.

Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
---
 lib/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/workqueue.c b/lib/workqueue.c
index 47cec9b..3b63463 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -69,7 +69,7 @@ int erofs_alloc_workqueue(struct erofs_workqueue *wq, unsigned int nworker,
 		ret = pthread_create(&wq->workers[i], NULL, worker_thread, wq);
 		if (ret) {
 			while (i)
-				pthread_cancel(wq->workers[--i]);
+				pthread_kill(wq->workers[--i]);
 			free(wq->workers);
 			return ret;
 		}
-- 
2.46.1.824.gd892dcdcdd-goog



More information about the Linux-erofs mailing list