From 4d2dbc74621c65e40bef1bbbd708fe387a129f29 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 12 Jun 2018 09:59:03 +0900 Subject: [PATCH] Add isf_control_set_socket_connect_timeout API Change-Id: I6e381ccc0d6d757a4e036b08d5a86e0a134f1a19 --- ism/src/isf_control.cpp | 7 +++++++ ism/src/isf_control.h | 13 +++++++++++++ ism/src/isf_imcontrol_client.cpp | 26 ++++++++++++++++++-------- ism/src/isf_imcontrol_client.h | 1 + 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ism/src/isf_control.cpp b/ism/src/isf_control.cpp index b769dc0..cb44448 100644 --- a/ism/src/isf_control.cpp +++ b/ism/src/isf_control.cpp @@ -600,6 +600,13 @@ EXAPI int isf_control_prelaunch_ise (void) return ret; } +EXAPI int isf_control_set_socket_connect_timeout (int msec) +{ + IMControlClient imcontrol_client; + imcontrol_client.set_socket_connect_timeout (msec); + + return 0; +} /* vi:ts=4:nowrap:ai:expandtab diff --git a/ism/src/isf_control.h b/ism/src/isf_control.h index 22c3e0e..9301a55 100644 --- a/ism/src/isf_control.h +++ b/ism/src/isf_control.h @@ -349,6 +349,19 @@ int isf_control_hide_ime (void); */ int isf_control_prelaunch_ise (void); +/** + * @brief Sets the timeout for socket connect requests. + * + * @remarks If the socket connection fails, retry the connection internally until the run-time has reached the timeout. + * + * @since_tizen 5.0 + * + * @param[in] msec The socket connect timeout. The timeout has a minimum unit of 100ms. + * + * @return 0 on success, otherwise return -1 + */ +int isf_control_set_socket_connect_timeout (int msec); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ism/src/isf_imcontrol_client.cpp b/ism/src/isf_imcontrol_client.cpp index edbf6f1..a767c6b 100644 --- a/ism/src/isf_imcontrol_client.cpp +++ b/ism/src/isf_imcontrol_client.cpp @@ -31,11 +31,13 @@ #include #include "scim.h" +#define MINIMUM_TIMEOUT 100 namespace scim { typedef Signal1 IMControlClientSignalVoid; +static int m_retry_count = 600; #if ENABLE_LAZY_LAUNCH static bool check_panel (const String &display) @@ -157,19 +159,15 @@ public: ret = m_socket_imclient2panel.connect (addr); ret2 = m_socket_panel2imclient.connect (addr); if (!ret) { - scim_usleep (100000); #if ENABLE_LAZY_LAUNCH if (!check_socket_frontend ()) launch_socket_frontend (); if (!check_panel (display)) scim_launch_panel (true, "socket", display, NULL); #endif - for (int i = 0; i < 200; ++i) { - if (m_socket_imclient2panel.connect (addr)) { - ret = true; - break; - } - scim_usleep (100000); + if (m_socket_imclient2panel.connect (addr)) { + ret = true; + break; } } @@ -180,7 +178,7 @@ public: m_socket_imclient2panel.close (); m_socket_panel2imclient.close (); - if (count++ >= 3) break; + if (count++ >= m_retry_count) break; scim_usleep (100000); } @@ -597,6 +595,13 @@ public: return false; } } + + void set_socket_connect_timeout (int msec) { + if (msec < MINIMUM_TIMEOUT) + m_retry_count = 1; + else + m_retry_count = msec / MINIMUM_TIMEOUT; + } }; IMControlClient::IMControlClient () @@ -732,6 +737,11 @@ bool IMControlClient::launch_helper_ise (void) { return m_impl->launch_helper_ise (); } + +void IMControlClient::set_socket_connect_timeout (int msec) +{ + return m_impl->set_socket_connect_timeout (msec); +} }; /* diff --git a/ism/src/isf_imcontrol_client.h b/ism/src/isf_imcontrol_client.h index 10685b8..0a43a61 100644 --- a/ism/src/isf_imcontrol_client.h +++ b/ism/src/isf_imcontrol_client.h @@ -68,6 +68,7 @@ public: void enable_remote_input (void); void disable_remote_input (void); bool launch_helper_ise (void); + void set_socket_connect_timeout (int msec); }; } -- 2.7.4