From c55fbd310d9a467effdbdf0e24010fce966900bc Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 22 二月 2021 15:59:21 +0800
Subject: [PATCH] 调整日志打印,判断rNodes
---
hbusc.go | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/hbusc.go b/hbusc.go
index 2ac944d..dcc569c 100644
--- a/hbusc.go
+++ b/hbusc.go
@@ -446,14 +446,17 @@
func (h *BHBus) Request(serverId string, req *MsgInfo, milliSecs int) (*Reply, error) {
//1.棣栧厛闇�瑕侀�氳繃topic鎷垮埌鏈満瀵瑰簲鐨凬etNode
rNodes, err := h.GetNetNodeByTopic(serverId, &req.SrcProc, req.Topic)
- h.printLog("topic", req.Topic, "rNodes:", rNodes, "err:", err)
if err != nil {
+ h.printLog("topic: ", req.Topic, " rNodes: ", rNodes, " err:", err)
return nil, err
+ }
+ if rNodes == nil || len(rNodes) == 0 {
+ return nil, errors.New("rNodes empty, topic: "+ req.Topic)
}
//2.灏嗚姹傝繑閫佸埌瀵瑰簲鐨剆erver,骞剁瓑寰呰繑鍥炲��
data, err := json.Marshal(*req)
- h.printLog("marshal(*req) err:", err)
if err != nil {
+ h.printLog("marshal(*req) err:", err)
return nil, err
}
var ret []bhomebus.Mesg
@@ -470,8 +473,8 @@
}
} else {
h.printLog("Request n: ", n, " len(ret): ", len(ret))
+ return nil, fmt.Errorf("request err, SendandrecvTimeout n:%d", n)
}
- return nil, fmt.Errorf("request err")
}
func (h *BHBus) RequestOnly(rData []byte, rNodes []bhomebus.NetNode) ([]byte, error) {
@@ -483,8 +486,8 @@
return ret[0].Data, nil
} else {
h.printLog("Request n: ", n, " len(ret): ", len(ret), "rData:", string(rData))
+ return nil, fmt.Errorf("request err, SendandrecvTimeout n:%d", n)
}
- return nil, fmt.Errorf("request err")
}
func (h *BHBus) Reply(replyKey int, i *Reply) error {
--
Gitblit v1.8.0