From 4ad4f24f18cf7d0af22ca885baebc6a3eb37e7d0 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期四, 20 五月 2021 10:08:40 +0800
Subject: [PATCH] rename socket.h/cpp to shm_socket.h/cpp.

---
 src/msg.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/msg.cpp b/src/msg.cpp
index a4777d2..dca2044 100644
--- a/src/msg.cpp
+++ b/src/msg.cpp
@@ -17,14 +17,16 @@
  */
 #include "msg.h"
 #include "bh_util.h"
-#include "socket.h"
+#include "defs.h"
+#include "shm_socket.h"
 
 namespace bhome_msg
 {
 
 ShmSocket &ShmMsg::Sender()
 {
-	static ShmSocket sender(shm(), false, BHGlobalSenderAddress(), 16);
+	static auto &mq = GetCenterInfo(shm())->mq_sender_;
+	static ShmSocket sender(mq.offset_, shm(), mq.id_);
 	return sender;
 }
 
@@ -35,10 +37,15 @@
 	}
 	auto n = meta()->count_.Dec();
 	if (n == 0) {
-		int64_t free_cmd = (id() << 4) | EncodeCmd(eCmdFree);
-		Sender().Send(BHTopicCenterAddress(), free_cmd);
+		if (meta()->managed_) {
+			int64_t free_cmd = (id() << 4) | EncodeCmd(eCmdFree);
+			Sender().Send(BHTopicCenterAddress(), free_cmd);
+		} else {
+			Free();
+		}
 	} else if (n < 0) {
-		throw -123;
+		LOG_FATAL() << "error double release data.";
+		throw std::runtime_error("double release msg.");
 	}
 	return n;
 }

--
Gitblit v1.8.0