Skip to contentSkip to conversation

Use pthread_kill instead of pthread_cancel for compatibility

PATCH New Kelvin Zhang via Linux-erofs 1 participant 1 message Oct 2, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use pthread_kill instead of pthread_cancel for compatibility

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.

---
 lib/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/workqueue.c +1 -1
index 47cec9b..3b63463 100644
@@ -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;
 		}
Signature · 1 line
2.46.1.824.gd892dcdcdd-goog