From patchwork Mon Mar 10 17:03:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22945 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 596C4C32F1 for ; Mon, 10 Mar 2025 17:03:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B4116891F; Mon, 10 Mar 2025 18:03:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="S4ubJhkI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF3D468890 for ; Mon, 10 Mar 2025 18:03:23 +0100 (CET) Received: from pb-laptop.local (185.221.143.221.nat.pool.zt.hu [185.221.143.221]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3215C227 for ; Mon, 10 Mar 2025 18:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1741626107; bh=LVBTW1IN6Gzw3DlnDC1hIAIMsLSIsCGuUEx2hzslnmM=; h=From:To:Subject:Date:From; b=S4ubJhkI2tfsm/kqhMUjcbX6/TvZdvQlO5k4m+osaRszTcQQW1M/8d//LPCPSj/iN fZ7YDAagyKzwUm6wy/IOhiSJINSF8wZU7FxvMKDZVxKsPD0kjoOvLYa542ixY45FdW lkEHdSkTFk8bLKrm8q6clfUxCmHDmezmuUM4celA= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] test: thread: Use `pthread_testcancel()` Date: Mon, 10 Mar 2025 18:03:18 +0100 Message-ID: <20250310170318.185249-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" `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 Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- 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; }