From: dyamy-lee Date: Tue, 13 Sep 2022 01:30:58 +0000 (+0900) Subject: add retry connection X-Git-Tag: accepted/tizen/unified/20220927.132357~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5ae7adbe9741102f2ef22d894f49fd694ab2507;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git add retry connection if connect_sync is fail or not connected when it invoke register, retry connection as sync again. Change-Id: Ibcec136ab0afdf9508d0a08087974a8639d8c5da --- diff --git a/src/mmi-ipc.c b/src/mmi-ipc.c index 889c55a..c14de7f 100644 --- a/src/mmi-ipc.c +++ b/src/mmi-ipc.c @@ -64,11 +64,27 @@ static void _on_rejected(rpc_port_proxy_mmi_h h, void *user_data) _connected = 0; } +int mmi_ipc_retry_connection(rpc_port_proxy_mmi_h h) +{ + LOGI("Retry connection"); + + if (mmi_ipc_is_connected() == false) { + LOGE("Not Connected."); + int ret = rpc_port_proxy_mmi_connect_sync(h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Fail to retry connection(%d)", ret); + return MMI_ERROR_OPERATION_FAILED; + } + } + + return MMI_ERROR_NONE; +} + int mmi_ipc_initialize(void) { /* initialize handles */ _rpc_h = NULL; - int r; + int ret; rpc_port_proxy_mmi_callback_s callback = { .connected = _on_connected, @@ -76,31 +92,26 @@ int mmi_ipc_initialize(void) .rejected = _on_rejected }; - r = rpc_port_proxy_mmi_create(_stub_appid, &callback, NULL, &_rpc_h); - if (r != RPC_PORT_ERROR_NONE) - { - LOGE("Failed to create mmi proxy handle ! (error:%d)\n", r); - goto err; + ret = rpc_port_proxy_mmi_create(_stub_appid, &callback, NULL, &_rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Failed to create mmi proxy handle ! (error:%d)\n", ret); + return MMI_ERROR_OPERATION_FAILED; } - r = rpc_port_proxy_mmi_connect_sync(_rpc_h); - if (r != RPC_PORT_ERROR_NONE) - { - LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r); - goto err; + ret = rpc_port_proxy_mmi_connect_sync(_rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Try to connect again"); + //Retry + ret = mmi_ipc_retry_connection(_rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Fail to retry connection(%d)", ret); + return MMI_ERROR_OPERATION_FAILED; + } } LOGI("connect mmi ipc"); - return 0; -err: - if (_rpc_h) - rpc_port_proxy_mmi_destroy(_rpc_h); - - rpc_port_deregister_proc_info(); - - _rpc_h = NULL; - return -1; + return MMI_ERROR_NONE; } void mmi_ipc_deinitialize(void) @@ -120,6 +131,7 @@ void mmi_ipc_deinitialize(void) int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_mmi_result_cb_cb callback) { LOGI("Register input event(%d) result cb to MMI Service", input_event_type); + int ret; if (callback == NULL) { LOGE("Parameter callback is NULL"); @@ -138,8 +150,17 @@ int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_ return MMI_ERROR_INVALID_PARAMETER; } + if (mmi_ipc_is_connected() == false) { + LOGE("Try to connect again"); + ret = mmi_ipc_retry_connection(rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Fail to retry connection(%d)", ret); + return MMI_ERROR_OPERATION_FAILED; + } + } + rpc_port_proxy_mmi_result_cb_h result_cb_h; - int ret = rpc_port_proxy_mmi_result_cb_create(&result_cb_h); + ret = rpc_port_proxy_mmi_result_cb_create(&result_cb_h); if (ret != RPC_PORT_ERROR_NONE) { LOGE("Failed to create result callback handle (error:%d)\n", ret); return MMI_ERROR_OPERATION_FAILED;