From patchwork Fri Mar 12 05:47:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11552 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 5809BBD1F1 for ; Fri, 12 Mar 2021 05:47:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 61E1768C71; Fri, 12 Mar 2021 06:47:33 +0100 (CET) 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="Cz+ySACz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE4B4605B2 for ; Fri, 12 Mar 2021 06:47:31 +0100 (CET) Received: from localhost.localdomain (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 789F08F9; Fri, 12 Mar 2021 06:47:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615528051; bh=GcS3UJ7IygbcEhkVyVKA3EqmAvhXexIHhbZv5jopVLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cz+ySACzj22PPIC5cu68EqEuKMlLlZfB40aApXjMFnDGrabv56b095M6f9e6ptd9e ybNS9z9ZZNAMObF0od553hXdvWzEOjRZF4CrkxPbRxWcl71yiFwBnKIW2u9516tp3E ZDxJe8dIKRewPGjhOU85+zzYTfZD/ZQeO0okKgJQ= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Mar 2021 05:47:20 +0000 Message-Id: <20210312054727.852622-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210312054727.852622-1-kieran.bingham@ideasonboard.com> References: <20210312054727.852622-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/8] utils: ipc: proxy: Assert asynchronous calls execute in the running state 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" From: Laurent Pinchart Signals and calls from the IPA should not occur after the IPA has been put into the stopped state. Add assertions to catch and prevent any messages being processed after this. Signed-off-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- .../generators/libcamera_templates/module_ipa_proxy.cpp.tmpl | 2 ++ utils/ipc/generators/libcamera_templates/proxy_functions.tmpl | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl index f75b1206cad4..e3b541db4e36 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl @@ -173,6 +173,7 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data) {%- endfor -%} ); {% elif method|is_async %} + ASSERT(running_); proxy_.invokeMethod(&ThreadProxy::{{method.mojom_name}}, ConnectionTypeQueued, {%- for param in method|method_param_names -%} {{param}}{{- ", " if not loop.last}} @@ -225,6 +226,7 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data) {% for method in interface_event.methods %} {{proxy_funcs.func_sig(proxy_name, method, "Thread")}} { + ASSERT(running_); {{method.mojom_name}}.emit({{method.parameters|params_comma_sep}}); } diff --git a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl index c2ac42fca45b..13dc8fdcab6e 100644 --- a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl +++ b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl @@ -26,12 +26,12 @@ if (!running_) return; - running_ = false; - proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking); thread_.exit(); thread_.wait(); + + running_ = false; {%- endmacro -%}