[PATCH v1] test: thread: Use `pthread_testcancel()`

Barnabás Pőcze barnabas.pocze at ideasonboard.com
Mon Mar 10 18:03:18 CET 2025


`pthread_testcancel()` is a guaranteed cancellation point,
specifically for testing if cancellation has been requested,
so use it.

Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>
---
 test/threads.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/test/threads.cpp b/test/threads.cpp
index 8d6ee1510..c00d95a41 100644
--- a/test/threads.cpp
+++ b/test/threads.cpp
@@ -52,14 +52,8 @@ protected:
 	{
 		cancelled_ = true;
 
-		/*
-		 * Cancel the thread and call a guaranteed cancellation point
-		 * (nanosleep).
-		 */
 		pthread_cancel(pthread_self());
-
-		struct timespec req{ 0, 100*000*000 };
-		nanosleep(&req, nullptr);
+		pthread_testcancel();
 
 		cancelled_ = false;
 	}
-- 
2.48.1



More information about the libcamera-devel mailing list