From 2de7ebf4516e58a8fa959977a51dccd22823c0e0 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期四, 06 五月 2021 18:58:35 +0800
Subject: [PATCH] fix node recursive lock.

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

diff --git a/src/topic_node.cpp b/src/topic_node.cpp
index f629597..3883062 100644
--- a/src/topic_node.cpp
+++ b/src/topic_node.cpp
@@ -44,7 +44,7 @@
 
 TopicNode::~TopicNode()
 {
-	printf("~TopicNode()\n");
+	LOG_DEBUG() << "~TopicNode()";
 	Stop();
 }
 
@@ -59,7 +59,7 @@
 	if (ssn_id_ == 0) {
 		ssn_id_ = ShmMsgQueue::NewId();
 	}
-	printf("Node Init, id %ld \n", ssn_id_);
+	LOG_DEBUG() << "Node Init, id " << ssn_id_;
 	MsgI msg;
 	msg.OffsetRef() = ssn_id_;
 	if (ShmMsgQueue::TrySend(shm(), BHInitAddress(), msg)) {
@@ -77,8 +77,6 @@
 
 void TopicNode::Start(ServerAsyncCB const &server_cb, SubDataCB const &sub_cb, RequestResultCB &client_cb, int nworker)
 {
-	std::lock_guard<std::mutex> lk(mutex_);
-
 	if (!Init()) {
 		SetLastError(eError, "BHome Node Not Inited.");
 		return;
@@ -95,9 +93,9 @@
 }
 void TopicNode::Stop()
 {
-	printf("Node Stopping\n");
+	LOG_DEBUG() << "Node Stopping";
 	for (auto &p : sockets_) { p->Stop(); }
-	printf("Node Stopped\n");
+	LOG_INFO() << "Node Stopped";
 }
 
 bool TopicNode::Register(ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms)
@@ -423,7 +421,7 @@
 
 		BHAddress addr;
 		if (ClientQueryRPCTopic(request.topic(), addr, timeout_ms)) {
-			// printf("node: %ld, topic dest: %ld\n", SockNode().id(), addr.mq_id());
+			LOG_TRACE() << "node: " << SockNode().id() << ", topic dest: " << addr.mq_id();
 			BHMsgHead head(InitMsgHead(GetType(request), proc_id(), ssn()));
 			AddRoute(head, sock.id());
 			head.set_topic(request.topic());

--
Gitblit v1.8.0