Retry socket connection of remote_control to prevent abort issue 31/155331/3
authorInHong Han <inhong1.han@samsung.com>
Thu, 12 Oct 2017 08:53:23 +0000 (17:53 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 13 Oct 2017 04:54:55 +0000 (04:54 +0000)
Change-Id: I22cdde585e4b985e5f03d38b0b4efa17d79752cc

ism/src/isf_remote_client.cpp

index 4712be8..ed1ead7 100644 (file)
@@ -38,6 +38,8 @@
 #endif
 #define LOG_TAG             "ISF_REMOTE_CLIENT"
 
+#define RETRY_COUNT     5
+
 namespace scim
 {
 
@@ -233,10 +235,15 @@ public:
         return true;
     }
 
-    bool has_pending_event (void) const {
+    bool has_pending_event (void) {
         if (m_socket_panel2remoteinput.is_connected () && m_socket_panel2remoteinput.wait_for_data (0) > 0)
             return true;
 
+        for (int i = 0; i < RETRY_COUNT; ++i) {
+            if (open_connection())
+                return true;
+        }
+
         return false;
     }
 
@@ -313,8 +320,12 @@ public:
     }
 
     remote_control_callback_type recv_callback_message(void) {
-        if (! m_socket_panel2remoteinput.is_connected () || ! m_trans_recv.read_from_socket(m_socket_panel2remoteinput, m_socket_timeout))
-            return REMOTE_CONTROL_CALLBACK_ERROR;
+        if (! m_socket_panel2remoteinput.is_connected () || ! m_trans_recv.read_from_socket(m_socket_panel2remoteinput, m_socket_timeout)) {
+            for (int i = 0; i < RETRY_COUNT; ++i) {
+                if (open_connection())
+                    break;
+            }
+        }
 
         int cmd;