Prevent isf-panel-efl from being launched multiple times 43/49743/1
authorSungmin Kwak <sungmin.kwak@samsung.com>
Thu, 8 Oct 2015 08:21:10 +0000 (17:21 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 20 Oct 2015 00:21:05 +0000 (09:21 +0900)
Change-Id: If66c0a908ac61de84970c60ac603bd11e0f48b50

ism/src/scim.cpp

index 4b38f4d..b29386e 100644 (file)
@@ -88,20 +88,29 @@ static bool check_panel (const String &display)
 {
     SocketAddress address;
     SocketClient client;
-
     uint32 magic;
+    struct tms     tiks_buf;
+    static clock_t start_tiks = (clock_t)0;
+    static double  clock_tiks = (double)sysconf (_SC_CLK_TCK);
+    clock_t curr_tiks = times (&tiks_buf);
+    double  secs = (double)(curr_tiks - start_tiks) / clock_tiks;
 
-    address.set_address (scim_get_default_panel_socket_address (display));
-
-    if (!client.connect (address))
-        return false;
+    if (secs > MIN_RETRY_TIME) {
+        address.set_address (scim_get_default_panel_socket_address (display));
 
-    if (!scim_socket_open_connection (magic,
-        String ("ConnectionTester"),
-        String ("Panel"),
-        client,
-        1000)) {
+        if (!client.connect (address)) {
+            start_tiks = curr_tiks;
             return false;
+        }
+
+        if (!scim_socket_open_connection (magic,
+            String ("ConnectionTester"),
+            String ("Panel"),
+            client,
+            1000)) {
+                start_tiks = curr_tiks;
+                return false;
+        }
     }
 
     return true;