Unregister TIDL stub port when connection is closed 07/290907/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 4 Apr 2023 09:16:17 +0000 (18:16 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Wed, 5 Apr 2023 01:46:54 +0000 (10:46 +0900)
- Issue:
Connected event callback is invoked even though the connection is
closed.

- Solution:
Previous code does not invoke unregister method of TIDL stub, so the
connection callback still can be invoked even if the client
succeeds to deinitialize. And this is no intended behavior, so this
patch fixes this behaivor. Through this patch, widget module will
properly call unregister method. And also, widget module will check
first if the stub information is valid.

Change-Id: I1864824237218468b5341eb32c23c17e9f278651
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/vc_widget_tidl.c

index b099088..55b2e09 100644 (file)
@@ -197,6 +197,8 @@ static rpc_port_proxy_vc_widget_proxy_vc_widget_h __create_rpc_port(const char*
 
 static void __vcd_widget_create_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data)
 {
+       RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl stub info");
+
        g_stub_tidl_info->connected = true;
        g_stub_tidl_info->register_callback_requesting = false;
 
@@ -216,6 +218,8 @@ static void __vcd_widget_create_cb(rpc_port_stub_vc_widget_stub_vcd_widget_conte
 
 static void __vcd_widget_terminate_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data)
 {
+       RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[ERROR] Fail to get tidl stub info");
+
        g_stub_tidl_info->connected = false;
        g_stub_tidl_info->register_callback_requesting = false;
 
@@ -243,6 +247,8 @@ static int __vcd_widget_asr_result_cb(rpc_port_stub_vc_widget_stub_vcd_widget_co
 
 static void __register_stub_callback()
 {
+       RETM_IF(NULL == g_stub_tidl_info, TAG_VCW, "[TIDL ERROR] g_stub_tidl_info is not allocated");
+
        if (g_stub_tidl_info->register_callback_requesting) {
                return;
        }
@@ -344,6 +350,12 @@ int vc_widget_tidl_close_connection()
        free(g_proxy_tidl_info);
        g_proxy_tidl_info = NULL;
 
+       if (0 != rpc_port_stub_vc_widget_stub_vcd_widget_unregister()) {
+               SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to unregister stub");
+               pthread_mutex_unlock(&g_w_tidl_mutex);
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
        free(g_stub_tidl_info);
        g_stub_tidl_info = NULL;