From a38304f7f6b91aaa1b0aa76cc9d3e5b6aef1f85f Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期六, 13 三月 2021 17:07:22 +0800
Subject: [PATCH] update

---
 src/queue/array_lock_free_queue.h |    1 
 src/queue/lock_free_queue.h       |   46 +++++++++++-----------
 src/socket/shm_socket.cpp         |   27 ++++++++++---
 3 files changed, 44 insertions(+), 30 deletions(-)

diff --git a/src/queue/array_lock_free_queue.h b/src/queue/array_lock_free_queue.h
index 5ff8daf..24efd10 100644
--- a/src/queue/array_lock_free_queue.h
+++ b/src/queue/array_lock_free_queue.h
@@ -102,6 +102,7 @@
 template<typename ELEM_T, typename Allocator>
 ArrayLockFreeQueue<ELEM_T, Allocator>::~ArrayLockFreeQueue() {
   // std::cout << "destroy ArrayLockFreeQueue\n";
+  
   Allocator::deallocate(m_theQueue);
 
 }
diff --git a/src/queue/lock_free_queue.h b/src/queue/lock_free_queue.h
index 54d0b04..31f2cc1 100644
--- a/src/queue/lock_free_queue.h
+++ b/src/queue/lock_free_queue.h
@@ -88,9 +88,9 @@
   sem_t slots;
   sem_t items;
 
-  time_t createTime;
-  time_t closeTime;
-  int status;
+  // time_t createTime;
+  // time_t closeTime;
+  // int status;
 
 public:
 
@@ -101,7 +101,7 @@
   /// template
   ~LockFreeQueue();
 
-  inline void  close();
+  // inline void  close();
 
   // std::atomic_uint reference;
   /// @brief constructor of the class
@@ -129,17 +129,17 @@
 
   
 
-  time_t getCreateTime() {
-    return createTime;
-  }
+  // time_t getCreateTime() {
+  //   return createTime;
+  // }
 
-  time_t getCloseTime() {
-    return closeTime;
-  }
+  // time_t getCloseTime() {
+  //   return closeTime;
+  // }
 
-  int getStatus() {
-    return status;
-  }
+  // int getStatus() {
+  //   return status;
+  // }
 
   /// @brief push an element at the tail of the queue
   /// @param the element to insert in the queue
@@ -182,20 +182,20 @@
   if (sem_init(&items, 1, 0) == -1)
     err_exit(errno, "LockFreeQueue sem_init");
   
-  createTime = time(NULL);
-  status = LOCK_FREE_Q_ST_OPENED;
+  // createTime = time(NULL);
+  // status = LOCK_FREE_Q_ST_OPENED;
 
 }
 
 
-template<
-  typename ELEM_T,
-  typename Allocator,
-  template<typename T, typename AT> class Q_TYPE>
-inline void LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::close() {
-  status = LOCK_FREE_Q_ST_CLOSED;
-  closeTime = time(NULL); 
-}
+// template<
+//   typename ELEM_T,
+//   typename Allocator,
+//   template<typename T, typename AT> class Q_TYPE>
+// inline void LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::close() {
+//   // status = LOCK_FREE_Q_ST_CLOSED;
+//   // closeTime = time(NULL); 
+// }
 
 
 template<
diff --git a/src/socket/shm_socket.cpp b/src/socket/shm_socket.cpp
index 4f5f4d9..1f5d47b 100644
--- a/src/socket/shm_socket.cpp
+++ b/src/socket/shm_socket.cpp
@@ -112,12 +112,9 @@
 
 static int _shm_socket_close_(shm_socket_t *sockt) {
   
-  int rv;
+  int rv, i;
   logger->debug("shm_socket_close\n");
-  // hashtable_remove(hashtable, mkey);
-  // if(sockt->queue != NULL) {
-  //   sockt->queue = NULL;
-  // }
+ 
 
   if(sockt->key != 0) {
     auto it =  shmQueueStMap->find(sockt->key);
@@ -127,6 +124,24 @@
     }
   }
 
+
+  printf("====sockt->queue addr = %p\n", sockt->queue);
+
+  if(sockt->queue != NULL) {
+    for( i = 0; i < sockt->queue->size(); i++) {
+      mm_free((*(sockt->queue))[i].buf);
+      logger->info("======= %d free queue element buf\n", sockt->key);
+    }
+
+    // hashtable_remove(hashtable, mkey);
+  //   sockt->queue = NULL;
+  }
+ 
+
+  // hashtable_remove(hashtable, mkey);
+  // if(sockt->queue != NULL) {
+  //   sockt->queue = NULL;
+  // }
  
 
   pthread_mutex_destroy(&(sockt->mutex) );
@@ -168,8 +183,6 @@
 int shm_socket_get_key(shm_socket_t *sockt){
   return sockt->key;
 }
-
-
 
 // 鐭繛鎺ユ柟寮忓彂閫�
 int shm_sendto(shm_socket_t *sockt, const void *buf, const int size,

--
Gitblit v1.8.0