From patchwork Sun May 23 02:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12365 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 3813DC3200 for ; Sun, 23 May 2021 02:32:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 01EA66891F; Sun, 23 May 2021 04:32:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aLudtdmh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D9EA68911 for ; Sun, 23 May 2021 04:32:02 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BC428E6; Sun, 23 May 2021 04:32:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1621737121; bh=sjECzHXvytrVhD5+5f8Jj7s9oMvnRca65S0EFXMcdSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLudtdmhTCjdi4BM5H4KJQOtfRn3ojGsV2GxBsoiEgOc6eatIPfpEimthgpf0hDcQ 16fD+zcrXN21tNImU+KiRxSBpz8udjmhVG6aDVURaQkaWZe1FEzW3bL01DLJjxWWn3 U8FYlAkZh/oyq0N3HPw8EWoNKqgVCpUReFfpbYqs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 23 May 2021 05:31:53 +0300 Message-Id: <20210523023155.20268-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.1 In-Reply-To: <20210523023155.20268-1-laurent.pinchart@ideasonboard.com> References: <20210523023155.20268-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: thread: Enforce dispatchMessages() call context with assert 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" The Thread::dispatchMessages() function is meant to be called from within the thread only. Catch incorrect usage with an ASSERT(). Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Umang Jain Reviewed-by: Hirokazu Honda --- src/libcamera/thread.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/thread.cpp b/src/libcamera/thread.cpp index 285b808332e8..bc1dcedea0d1 100644 --- a/src/libcamera/thread.cpp +++ b/src/libcamera/thread.cpp @@ -560,6 +560,8 @@ void Thread::removeMessages(Object *receiver) */ void Thread::dispatchMessages(Message::Type type) { + ASSERT(data_ == ThreadData::current()); + MutexLocker locker(data_->messages_.mutex_); std::list> &messages = data_->messages_.list_;