[libcamera-devel,v3,1/6] utils: ipc: proxy: Assert asynchronous calls execute in the running state
diff mbox series

Message ID 20210324150125.1318325-2-kieran.bingham@ideasonboard.com
State Accepted
Delegated to: Kieran Bingham
Headers show
Series
  • IPU3 Stability
Related show

Commit Message

Kieran Bingham March 24, 2021, 3:01 p.m. UTC
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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 <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 .../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(-)

Patch
diff mbox series

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 -%}