shared memory: deallocate when click "Forse Close"
authormunkyu.im <munkyu.im@samsung.com>
Thu, 31 Jan 2013 09:37:43 +0000 (18:37 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Thu, 31 Jan 2013 09:37:43 +0000 (18:37 +0900)
Deallocate shared memory related to skin.

Signed-off-by: munkyu.im <munkyu.im@samsung.com>
tizen/src/hw/maru_vga.c [changed mode: 0644->0755]
tizen/src/skin/maruskin_operation.c

old mode 100644 (file)
new mode 100755 (executable)
index 89bebfb..a6788be
@@ -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: ");
     }
index ec09d7c..52a5e36 100644 (file)
 #include "target-i386/hax-i386.h"
 #endif
 
+#if defined(CONFIG_USE_SHM)
+#include <sys/shm.h>
+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;