Modified open_connection logic when the helper_active connection is failed 33/106033/3
authorInHong Han <inhong1.han@samsung.com>
Tue, 20 Dec 2016 08:22:13 +0000 (17:22 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 21 Dec 2016 05:34:53 +0000 (14:34 +0900)
Change-Id: I2f6585c8de65939af5907c26b0600612e86bf181

ism/src/scim_helper.cpp

index cd77f26..629f700 100644 (file)
@@ -705,14 +705,30 @@ HelperAgent::open_connection (const HelperInfo &info,
 
     /* connect to the panel agent as the active helper client */
     if (!m_impl->socket_active.connect (address)) return -1;
-    if (!scim_socket_open_connection (magic,
+    open_connection_retries = 0;
+    while (!scim_socket_open_connection (magic,
                                       String ("Helper_Active"),
                                       String ("Panel"),
                                       m_impl->socket_active,
                                       timeout)) {
-        m_impl->socket_active.close ();
-        ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection() failed %d\n", timeout);
-        return -1;
+        if (++open_connection_retries > 10) {
+            m_impl->socket_active.close ();
+            std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
+            ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
+            ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
+
+            return -1;
+        }
+
+        /* Retry after re-connecting the socket */
+        if (m_impl->socket_active.is_connected ())
+            m_impl->socket_active.close ();
+
+        /* This time, just retry atmost 2 seconds */
+        i = 0;
+        while (!m_impl->socket_active.connect (address) && ++i < 10) {
+            scim_usleep (200000);
+        }
     }
 
     m_impl->magic_active = magic;