From: Munkyu Im Date: Mon, 16 Jun 2014 09:12:51 +0000 (+0900) Subject: osutil: Add unlock function X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~139^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cde9151bbb6228aa4bc92568f5df3312087f506;p=sdk%2Femulator%2Fqemu.git osutil: Add unlock function Need unlock funtion to release or free variables. Change-Id: I7a74edab9637bcf1ab4623b4c1189bba1487956c Signed-off-by: Munkyu Im --- diff --git a/tizen/src/osutil-darwin.c b/tizen/src/osutil-darwin.c index a56f47c3df..2cb637b566 100644 --- a/tizen/src/osutil-darwin.c +++ b/tizen/src/osutil-darwin.c @@ -116,6 +116,14 @@ void make_vm_lock_os(void) } +void make_vm_unlock_os(void) +{ + if (shmctl(g_shmid, IPC_RMID, 0) == -1) { + ERR("shmctl failed\n"); + perror("osutil-linux: "); + } +} + void set_bin_path_os(gchar * exec_argv) { gchar *file_name = NULL; diff --git a/tizen/src/osutil-linux.c b/tizen/src/osutil-linux.c index a5e9454522..395f9406f8 100644 --- a/tizen/src/osutil-linux.c +++ b/tizen/src/osutil-linux.c @@ -150,6 +150,15 @@ void make_vm_lock_os(void) } } +void make_vm_unlock_os(void) +{ + if (shmctl(g_shmid, IPC_RMID, 0) == -1) { + ERR("shmctl failed\n"); + perror("osutil-linux: "); + } +} + + void set_bin_path_os(gchar * exec_argv) { gchar link_path[PATH_MAX] = { 0, }; diff --git a/tizen/src/osutil-win32.c b/tizen/src/osutil-win32.c index 9403c2678a..5769dc6ddf 100644 --- a/tizen/src/osutil-win32.c +++ b/tizen/src/osutil-win32.c @@ -54,6 +54,8 @@ MULTI_DEBUG_CHANNEL (emulator, osutil); static qemu_timeval tv = { 0, 0 }; static time_t ti; static char buf_time[64]; +HANDLE g_hMapFile; +char *g_pBuf; extern char tizen_target_img_path[]; @@ -99,8 +101,6 @@ void check_vm_lock_os(void) void make_vm_lock_os(void) { - HANDLE hMapFile; - char *pBuf; char *port_in_use; char *shared_memory; int base_port; @@ -108,30 +108,41 @@ void make_vm_lock_os(void) base_port = get_emul_vm_base_port(); shared_memory = g_strdup_printf("%s", tizen_target_img_path); port_in_use = g_strdup_printf("%d", base_port); - hMapFile = CreateFileMapping( + g_hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, /* use paging file */ NULL, /* default security */ PAGE_READWRITE, /* read/write access */ 0, /* maximum object size (high-order DWORD) */ 50, /* maximum object size (low-order DWORD) */ port_in_use); /* name of mapping object */ - if (hMapFile == NULL) { + if (g_hMapFile == NULL) { ERR("Could not create file mapping object (%d).\n", GetLastError()); return; } - pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 50); - if (pBuf == NULL) { + g_pBuf = MapViewOfFile(g_hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 50); + if (g_pBuf == NULL) { ERR("Could not map view of file (%d).\n", GetLastError()); - CloseHandle(hMapFile); + CloseHandle(g_hMapFile); return; } - CopyMemory((PVOID)pBuf, shared_memory, strlen(shared_memory)); + CopyMemory((PVOID)g_pBuf, shared_memory, strlen(shared_memory)); free(port_in_use); free(shared_memory); } +void make_vm_unlock_os(void) +{ + if (g_pBuf != NULL) { + UnmapViewOfFile(g_pBuf); + } + if(hMapFile != NULL) { + CloseHandle(g_hMapFile); + } +} + + void set_bin_path_os(gchar * exec_argv) { gchar link_path[PATH_MAX] = { 0, }; diff --git a/tizen/src/osutil.h b/tizen/src/osutil.h index 80f34fa925..12abfdad39 100644 --- a/tizen/src/osutil.h +++ b/tizen/src/osutil.h @@ -62,6 +62,7 @@ extern const char *pac_tempfile; void check_vm_lock_os(void); void make_vm_lock_os(void); +void make_vm_unlock_os(void); void set_bin_path_os(gchar *);