Add logic to avoid reconnetion when finalize 45/281945/1 accepted/tizen/unified/20220926.025525
authorwn.jang <wn.jang@samsung.com>
Fri, 23 Sep 2022 07:50:49 +0000 (16:50 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Fri, 23 Sep 2022 10:23:35 +0000 (19:23 +0900)
Cause: The on_disconnect() cb is called, even a client requtests to disconnect.

Change-Id: I463ad1321968cc86b775125b220dfc8f1ce8b9b3
Solution: Check whether ipc listening state or not when tries to reconnect.

client/vc.c
client/vc_client.c
client/vc_client.h
client/vc_tidl.c

index 1e2cdad..2f18575 100644 (file)
@@ -404,6 +404,9 @@ static void __vc_internal_unprepare(void)
                SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE
        }
 
+       /* TODO set_start_listening should be move to proper place */
+       vc_client_set_start_listening(false);
+
        if (NULL != g_focus_in_handler) {
                ecore_event_handler_del(g_focus_in_handler);
                g_focus_in_handler = NULL;
@@ -599,6 +602,8 @@ static Eina_Bool __vc_connect_daemon(void *data)
                SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] The current client is not valid. It is destroyed."); //LCOV_EXCL_LINE
                return EINA_FALSE;
        }
+       /* TODO set_start_listening should be move to proper place */
+       vc_client_set_start_listening(true);
 
        SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon DONE");
 
index 442ac1f..601b840 100644 (file)
@@ -69,6 +69,9 @@ typedef struct {
 
        /* Invocation name */
        char*   invocation_name;
+
+       /* Listening IPC message from service */
+       bool    start_listening;
 } vc_client_s;
 
 static vc_client_s *g_client = NULL;
@@ -124,6 +127,7 @@ int vc_client_create(void)
 
        g_client->is_foreground = false;
        g_client->invocation_name = NULL;
+       g_client->start_listening = false;
 
        SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. pid(%u)", g_client->pid);
 
@@ -616,3 +620,20 @@ int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback,
 
        return VC_ERROR_NONE;
 }
+
+int vc_client_set_start_listening(bool is_listening_started)
+{
+       if (NULL == g_client)
+               return VC_ERROR_INVALID_PARAMETER;
+
+       g_client->start_listening = is_listening_started;
+       return VC_ERROR_NONE;
+}
+
+bool vc_client_is_listening_started()
+{
+       if (NULL == g_client)
+               return false;
+
+       return g_client->start_listening;
+}
\ No newline at end of file
index 21c3ea9..3505421 100644 (file)
@@ -126,6 +126,9 @@ int vc_client_set_tts_utterance_status_cb(vc_tts_utterance_status_cb callback, v
 
 int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback, void** user_data);
 
+int vc_client_set_start_listening(bool is_listening_started);
+
+bool vc_client_is_listening_started();
 
 #ifdef __cplusplus
 }
index b9c5a18..b38097e 100644 (file)
@@ -18,6 +18,7 @@
 #include "vc_tidl.h"
 #include "vc_proxy.h"
 #include "vc_main.h"
+#include "vc_client.h"
 
 #include <vconf.h>
 
@@ -113,8 +114,9 @@ static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 
        /* retry to connect */
        SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server");
-       __vc_cb_error(VC_ERROR_SERVICE_RESET, "Server Disconnected");
-
+       if (vc_client_is_listening_started()) {
+               __vc_cb_error(VC_ERROR_SERVICE_RESET, "Server Disconnected");
+       }
 }
 
 static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
@@ -502,17 +504,6 @@ int vc_tidl_request_finalize(int pid)
                return ret;
        }
 
-       ret = rpc_port_proxy_vc_proxy_vc_disconnect(info->rpc_h);
-       exception = get_last_result();
-       if (RPC_PORT_ERROR_NONE != exception) {
-               ret = __convert_unhandled_error(exception);
-       }
-
-       if (VC_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to disconnect. err(%d)", ret);
-               return ret;
-       }
-
        SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret);
 
        return VC_ERROR_NONE;