send connection request in thread on windows during sdb booting time
authorshingil.kang <shingil.kang@samsung.com>
Fri, 5 Jun 2015 08:38:15 +0000 (17:38 +0900)
committershingil.kang <shingil.kang@samsung.com>
Fri, 5 Jun 2015 12:04:56 +0000 (21:04 +0900)
to prevent emulator with no shared memory information being not detected

Change-Id: If81181bbc1723400d2e251d4a6ef29301afdf6ee
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/sdb.c
src/transport_local.c

index 9a9adc38241e7b8688fe242d38747d7b813725e2..f92d0e4eb883983758fb9485275a0a77c5eeaa3a 100755 (executable)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -49,6 +49,7 @@ static BOOL WINAPI ctrlc_handler(DWORD type)
     exit(STATUS_CONTROL_C_EXIT);
     return TRUE;
 }
+static void *local_init_thread(void *x);
 #endif
 
 void sdb_cleanup(void)
@@ -133,7 +134,18 @@ int sdb_main(int is_daemon, int server_port)
     install_listener(DEFAULT_SDB_QEMU_PORT, 0, NULL, qemuListener);
 
     sdb_usb_init();
+
+#ifdef OS_WINDOWS
+    sdb_thread_t thr;
+    void* (*func)(void *);
+    func = local_init_thread;
+    if(sdb_thread_create(&thr, func, NULL)) {
+        LOG_INFO("failed to create local init thread\n");
+        local_init(DEFAULT_SDB_LOCAL_TRANSPORT_PORT);
+    }
+#else
     local_init(DEFAULT_SDB_LOCAL_TRANSPORT_PORT);
+#endif
 
     LOG_INFO("Event loop starting\n");
     FDEVENT_LOOP();
@@ -142,6 +154,18 @@ int sdb_main(int is_daemon, int server_port)
     return 0;
 }
 
+#ifdef OS_WINDOWS
+static void *local_init_thread(void *x) {
+       int port = DEFAULT_SDB_LOCAL_TRANSPORT_PORT;
+       int count = SDB_LOCAL_TRANSPORT_MAX;
+
+       LOG_INFO("try to connect to emulator instances when booting sdb server up\n");
+       for (; count > 0; count--, port += 10) {
+               (void) local_connect(port, NULL);
+       }
+}
+#endif
+
 static void local_init(int port)
 {
     if(port < 1024) {
index 8ac4ae2914fc0d5f88a8720f0d29ae2ecbbcc768..79f7c1af7998d05d932dfe4526f9ddad6c9c7f9a 100755 (executable)
@@ -84,13 +84,16 @@ int local_connect(int sdb_port, const char *device_name) {
 
     char buf[64];
 
-    // in case of windows, it takes a long time to connect localhost compare to linux
+/* FIXED : send connection request in thread on windows in sdb booting time
+           to prevent emulator with no shared memory information being not detected */
+/*
 #if defined(OS_WINDOWS)
     char devname[DEVICENAME_MAX]={0,};
     if (get_devicename_from_shdmem(sdb_port, devname) == -1) {
         s_strncpy(devname, DEFAULT_DEVICENAME, DEVICENAME_MAX);
     }
 #endif
+*/
 
     char* host = "127.0.0.1";
     int fd = sdb_host_connect(host, sdb_port, SOCK_STREAM);