From: munkyu.im Date: Thu, 31 Jan 2013 09:37:43 +0000 (+0900) Subject: shared memory: deallocate when click "Forse Close" X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1088 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d3d1d9c81eee68b9d541c5d18636853a329dc4f;p=sdk%2Femulator%2Fqemu.git shared memory: deallocate when click "Forse Close" Deallocate shared memory related to skin. Signed-off-by: munkyu.im --- diff --git a/tizen/src/hw/maru_vga.c b/tizen/src/hw/maru_vga.c old mode 100644 new mode 100755 index 89bebfbc7f..a6788be930 --- a/tizen/src/hw/maru_vga.c +++ b/tizen/src/hw/maru_vga.c @@ -60,8 +60,8 @@ #ifdef CONFIG_USE_SHM void *shared_memory = (void*) 0; -int shmid; -int shmid_tmp; +int skin_shmid; +int port_shmid; #endif @@ -1876,14 +1876,14 @@ void maru_vga_common_init(VGACommonState *s) int mykey; void *temp; - shmid_tmp = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT); - if (shmid_tmp == -1) { + port_shmid = shmget((key_t)SHMKEY, (size_t)MAXLEN, 0666 | IPC_CREAT); + if (port_shmid == -1) { ERR("shmget failed\n"); perror("maru_vga: "); exit(1); } - temp = shmat(shmid_tmp, (char*)0x0, 0); + temp = shmat(port_shmid, (char*)0x0, 0); if (temp == (void *)-1) { ERR("shmat failed\n"); perror("maru_vga: "); @@ -1895,8 +1895,8 @@ void maru_vga_common_init(VGACommonState *s) INFO("shared memory key: %d, vga ram_size : %d\n", mykey, s->vram_size); - shmid = shmget((key_t)mykey, (size_t)s->vram_size, 0666 | IPC_CREAT); - if (shmid == -1) { + skin_shmid = shmget((key_t)mykey, (size_t)s->vram_size, 0666 | IPC_CREAT); + if (skin_shmid == -1) { ERR("shmget failed\n"); perror("maru_vga: "); maru_register_exit_msg(MARU_EXIT_UNKNOWN, (char*)"Cannot launch this VM.\n" @@ -1904,7 +1904,7 @@ void maru_vga_common_init(VGACommonState *s) exit(0); } - shared_memory = shmat(shmid, (void*)0, 0); + shared_memory = shmat(skin_shmid, (void*)0, 0); if (shared_memory == (void *)-1) { ERR("shmat failed\n"); perror("maru_vga: "); @@ -1925,12 +1925,12 @@ void maru_vga_common_fini(void) perror("maru_vga: "); } - if (shmctl(shmid, IPC_RMID, 0) == -1) { + if (shmctl(skin_shmid, IPC_RMID, 0) == -1) { ERR("shmctl failed\n"); perror("maru_vga: "); } - if (shmctl(shmid_tmp, IPC_RMID, 0) == -1) { + if (shmctl(port_shmid, IPC_RMID, 0) == -1) { ERR("temp shmctl failed\n"); perror("maru_vga: "); } diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index ec09d7c5d7..52a5e36fc4 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -55,6 +55,12 @@ #include "target-i386/hax-i386.h" #endif +#if defined(CONFIG_USE_SHM) +#include +int g_shmid; +extern int port_shmid; +#endif + MULTI_DEBUG_CHANNEL(qemu, skin_operation); #define RESUME_KEY_SEND_INTERVAL 500 // milli-seconds @@ -73,7 +79,6 @@ extern pthread_mutex_t mutex_screenshot; extern pthread_cond_t cond_screenshot; extern int tizen_base_port; - static void* run_timed_shutdown_thread(void* args); static void send_to_emuld(const char* request_type, int request_size, const char* send_buf, int buf_size); @@ -555,6 +560,18 @@ static void* run_timed_shutdown_thread( void* args ) { } INFO( "Shutdown qemu !!!\n" ); +#if defined(CONFIG_USE_SHM) + if (shmctl(g_shmid, IPC_RMID, 0) == -1) { + ERR("shmctl failed\n"); + perror("maru_sdl.c: "); + } + + if (shmctl(port_shmid, IPC_RMID, 0) == -1) { + ERR("shmctl failed\n"); + perror("maru_sdl.c: "); + } +#endif + qemu_system_shutdown_request(); return NULL;