From 3513eea6ac7049e696d6c1a6e7f2120a7f2529c5 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期六, 30 一月 2021 11:07:22 +0800
Subject: [PATCH] 不用mtxWorker锁,sendandrecv是线程安全的

---
 hbusc.go |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hbusc.go b/hbusc.go
index a7ed46e..12927e8 100644
--- a/hbusc.go
+++ b/hbusc.go
@@ -48,7 +48,7 @@
 	sockSub *sockClient  //璁㈤槄涓婚鐨剆ocket锛岀嚎绋嬪疄鏃舵帴鏀舵秷鎭紝闇�瑕佸崟鐙鐞�
 
 	sockWorker 	*sockClient  //鍙戠粰浠绘剰鐨剆erver,鐭殏鐨剅equest client
-	mtxWorker 	sync.Mutex	 //SendAndRecv鍙兘涓嶆槸绾跨▼瀹夊叏鐨�
+	//mtxWorker 	sync.Mutex	 //SendAndRecv鍙兘涓嶆槸绾跨▼瀹夊叏鐨�
 
 	chSub chan TransInfo
 	chReply chan TransInfo
@@ -273,8 +273,8 @@
 		return err
 	}
 
-	h.mtxWorker.Lock()
-	defer h.mtxWorker.Unlock()
+	//h.mtxWorker.Lock()
+	//defer h.mtxWorker.Unlock()
 	netNodes := append([]bhomebus.NetNode{}, bhomebus.NetNode{
 		Key: h.conf.regKey,
 	})
@@ -490,8 +490,8 @@
 	if err != nil {
 		return err
 	}
-	h.mtxWorker.Lock()
-	defer h.mtxWorker.Unlock()
+	//h.mtxWorker.Lock()
+	//defer h.mtxWorker.Unlock()
 	n := h.sockWorker.sock.SendtoTimeout(data, key, h.conf.sendTimeOut)
 	if n != 0 {
 		return fmt.Errorf("sendOnly ret n:%d", n)
@@ -507,8 +507,8 @@
 	rNodes := append([]bhomebus.NetNode{}, bhomebus.NetNode{
 		Key: KEY_QUERY,
 	})
-	h.mtxWorker.Lock()
-	defer h.mtxWorker.Unlock()
+	//h.mtxWorker.Lock()
+	//defer h.mtxWorker.Unlock()
 	var ret []bhomebus.Mesg
 	n := h.sockWorker.sock.SendandrecvTimeout(rNodes, data,&ret, h.conf.sendTimeOut)
 	h.printLog("requestCenter n:", n, "len(ret):", len(ret))

--
Gitblit v1.8.0