Assure that client always registers the callback in sync prepare 94/284594/3
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 21 Nov 2022 10:37:27 +0000 (19:37 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 22 Nov 2022 01:58:07 +0000 (10:58 +0900)
- Issue:
Sometimes, the message receive callback registration is skipped even if
the connection is normal.

- Solution:
The client lib always checks the 'register_callback_invoked' flag, but
this flag may not be set properly some cases even if client tries to
prepare synchronously. Thus, this patch removes the flag checking code
from synchronous prepare logic. The synchronous prepare should insure
the invocation of all protocol, so through this patch, the all step of
preparation will be invoked.

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

index c87914a..36bfa0e 100644 (file)
@@ -138,7 +138,6 @@ static void __on_connected(rpc_port_proxy_tts_h h, void *user_data)
 
        info->connected = true;
        info->connection_requesting = false;
-       info->register_callback_invoked = false;
 
        SLOG(LOG_DEBUG, TAG_TTSC, "Connected to server");
 }
@@ -328,6 +327,7 @@ static int __invoke_register_callback(int pid, tts_mode_e mode, int registered_e
                return ret;
        }
 
+       SLOG(LOG_ERROR, TAG_TTSC, ">>>>> Request register cb. uid(%d)", info->uid);
        rpc_port_proxy_tts_invoke_register_cb(info->rpc_h, pid, info->uid, (int)mode, registered_event_mask, info->notify_cb_h);
        info->register_callback_invoked = true;
        return TTS_ERROR_NONE;
@@ -403,30 +403,28 @@ static int __convert_unhandled_error(int ret)
 
 static int __invoke_register_callback_sync(int pid, tts_tidl_info_s* info)
 {
-       if (info->register_callback_invoked) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Already register callback is invoked");
-               return TTS_ERROR_NONE;
-       }
-
        int ret = TTS_ERROR_NONE;
+
        ret = __create_notify_callback_handle(info);
        if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create callback handle. ret(%d/%s)", ret, get_error_message(ret));
                return ret;
        }
 
+       info->register_callback_invoked = true;
+       SLOG(LOG_ERROR, TAG_TTSC, ">>>>> Request register cb sync. uid(%d)", info->uid);
        ret = rpc_port_proxy_tts_invoke_register_cb_sync(info->rpc_h, pid, info->uid, info->notify_cb_h);
        int exception = get_last_result();
        if (RPC_PORT_ERROR_NONE != exception) {
                ret = __convert_unhandled_error(exception);
        }
+       info->register_callback_invoked = false;
 
        if (TTS_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to register callback. ret(%d/%s)", ret, get_error_message(ret));
                return ret;
        }
 
-       info->register_callback_invoked = true;
        return TTS_ERROR_NONE;
 }
 
@@ -480,8 +478,8 @@ int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registere
                ret = __convert_unhandled_error(exception);
        }
 
+       SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : ret(%d/%s)", ret, get_error_message(ret));
        if (TTS_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
                return ret;
        }
 
@@ -504,15 +502,14 @@ int tts_tidl_request_finalize(unsigned int uid)
 
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
-
        int ret = rpc_port_proxy_tts_invoke_finalize(info->rpc_h, uid);
        int exception = get_last_result();
        if (RPC_PORT_ERROR_NONE != exception) {
                ret = __convert_unhandled_error(exception);
        }
 
+       SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize. ret(%d/%s)", ret, get_error_message(ret));
        if (TTS_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to invoke message");
                return ret;
        }