From 2b1f534ea407a8ec0b94e0389a360f6cdff54598 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期三, 08 九月 2021 14:02:38 +0800
Subject: [PATCH] call C.BHFree after return success

---
 src/shm/mm.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/shm/mm.cpp b/src/shm/mm.cpp
index 2b52b51..e4ef672 100644
--- a/src/shm/mm.cpp
+++ b/src/shm/mm.cpp
@@ -113,7 +113,6 @@
 
   newsize = ALIGN(size +  (SIZE_T_SIZE << 1) +  (PTR_SIZE << 1) );
 
-    //fprintf(stderr, "mm_malloc : size=%u\n", size);
   /* Search the free list for a fit */
   SemUtil::dec(mutex);
   if ((ptr = find_fit(newsize)) != NULL)
@@ -123,8 +122,11 @@
     return aptr;
   } else {
     SemUtil::inc(mutex);
-    abort();
-    err_exit(0, "mm_malloc : out of memery\n");
+    err_msg(0, "mm_malloc : out of memery\n");
+    LoggerFactory::getLogger()->fatal("mm_malloc : out of memery\n");
+    // abort();
+    exit(1);
+    
     return NULL;
   }
 
@@ -254,6 +256,7 @@
     first = false;
     shmid  = shmget(SHM_KEY, 0, 0);
   }
+
   if (shmid == -1)
     err_exit(errno, "mm_init shmget");
   shmp = shmat(shmid, key_addr, 0);
@@ -336,8 +339,6 @@
       else 
          LoggerFactory::getLogger()->debug("shared memory destroy\n");
 
-      LoggerFactory::getLogger()->debug( "mm_destroy: real destroy.");
-
       SemUtil::inc(mutex);
       SemUtil::remove(mutex);
       return true;
@@ -361,6 +362,7 @@
 
 void mm_free_by_key(int key) {
   void *ptr;
+
   ptr = hashtable_get(hashtable, key);
   if(ptr != NULL) {
     mm_free(ptr);

--
Gitblit v1.8.0