From patchwork Wed Mar 24 15:01: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: 11695 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 C1D3CC32E5 for ; Wed, 24 Mar 2021 15:01:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1893A602E3; Wed, 24 Mar 2021 16:01:34 +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="WyKf+r6r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 64AF5602E3 for ; Wed, 24 Mar 2021 16:01:31 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BADFE8F3; Wed, 24 Mar 2021 16:01:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616598091; bh=vQKpfhkgfbyPBUPGapP8weKWmKAw3k6l5cBEmmYLjSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WyKf+r6r1cOKuGrB0R3pjqau6zpBOMuzP6L28L6pHTMEkjlPVvFK9k0GDKzjTHeBe kYmt2MZMkIsxRevhW/A2/3UyEd5iO02Jlet0IiWKiB4HRI2sdmRGmE/3Qgp9QetK63 fMOpaABXfB+YS/qXDs6lR+rzAz4GOYRCWuoKjNMo= From: Kieran Bingham To: libcamera devel Date: Wed, 24 Mar 2021 15:01:20 +0000 Message-Id: <20210324150125.1318325-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210324150125.1318325-1-kieran.bingham@ideasonboard.com> References: <20210324150125.1318325-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/6] 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. Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- .../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 -%}