From bba5904e8e288556cf3e6acace7f0349cb21d2d2 Mon Sep 17 00:00:00 2001 From: "munkyu.im" Date: Fri, 27 Jul 2012 16:07:45 +0900 Subject: [PATCH] [Title]fix checking multi instance on windows [Type]Bugfix [Module] [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- tizen/src/emulator.c | 47 +---------------------------------------------- tizen/src/sdb.c | 4 ++-- tizen/src/sdb.h | 1 + 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 204a011..acf3dca 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -91,42 +91,6 @@ void exit_emulator(void) maru_display_fini(); } -static int check_port_bind_listen(u_int port) -{ - struct sockaddr_in addr; - int s, opt = 1; - int ret = -1; - socklen_t addrlen = sizeof(addr); - memset(&addr, 0, addrlen); - - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = INADDR_ANY; - addr.sin_port = htons(port); - - if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) || - (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) || - (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) || - (listen(s,1) < 0)) { - - /* fail */ - ret = -1; - ERR( "check port(%d) bind listen fail \n", port); - }else{ - /*fsucess*/ - ret = 1; - INFO( "check port(%d) bind listen ok \n", port); - } - -#ifdef CONFIG_WIN32 - closesocket(s); -#else - close(s); -#endif - - return ret; -} - - void check_shdmem(void) { #if defined(CONFIG_LINUX) @@ -195,18 +159,10 @@ void check_shdmem(void) { ERR("Could not map view of file (%d).\n", GetLastError()); CloseHandle(hMapFile); - return -1; } if(strcmp(pBuf, tizen_target_path) == 0) { - if(check_port_bind_listen(port+1) > 0) - { - UnmapViewOfFile(pBuf); - CloseHandle(hMapFile); - continue; - } - maru_register_exit_msg(MARU_EXIT_UNKNOWN, "Can not execute this VM.\nThe same name is running now."); UnmapViewOfFile(pBuf); CloseHandle(hMapFile); @@ -521,8 +477,6 @@ void prepare_maru(void) { INFO("Prepare maru specified feature\n"); - sdb_setup(); - INFO("call construct_main_window\n"); construct_main_window(skin_argc, skin_argv, qemu_argc, qemu_argv); @@ -548,6 +502,7 @@ int main(int argc, char* argv[]) check_shdmem(); make_shdmem(); + sdb_setup(); system_info(); diff --git a/tizen/src/sdb.c b/tizen/src/sdb.c index 4291fdd..90a5cf1 100644 --- a/tizen/src/sdb.c +++ b/tizen/src/sdb.c @@ -213,7 +213,7 @@ int inet_strtoip(const char* str, uint32_t *ip) return 0; } -static int check_port_bind_listen(u_int port) +int check_port_bind_listen(uint32_t port) { struct sockaddr_in addr; int s, opt = 1; @@ -254,7 +254,7 @@ int get_sdb_base_port(void) { int tries = 10; int success = 0; - u_int port = 26100; + uint32_t port = 26100; if(tizen_base_port == 0){ diff --git a/tizen/src/sdb.h b/tizen/src/sdb.h index b309516..5fc95db 100644 --- a/tizen/src/sdb.h +++ b/tizen/src/sdb.h @@ -110,4 +110,5 @@ int inet_strtoip(const char* str, uint32_t *ip); int socket_send(int fd, const void* buf, int buflen); void socket_close(int fd); void notify_sdb_daemon_start(void); +int check_port_bind_listen(uint32_t port); int sdb_loopback_client(int port, int type); -- 2.7.4