From c4e51a45643377624f80829066d99008c6623458 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期三, 06 一月 2021 17:13:08 +0800 Subject: [PATCH] recvRoutine添加日志 --- hbusc.go | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hbusc.go b/hbusc.go index bb9281e..8581eb7 100644 --- a/hbusc.go +++ b/hbusc.go @@ -55,12 +55,13 @@ } //鑾峰彇鍏朵粬杩涚▼鍙戠粰姝ocket鐨勬秷鎭�,鍙互鏄痵ub鐨勬帴鏀讹紝涔熷彲浠ユ槸reply鐨勬帴鏀躲�� -func recvRoutine(ctx context.Context, s *bhomebus.Socket, wg *sync.WaitGroup, ch chan<-TransInfo) { +func recvRoutine(ctx context.Context, s *bhomebus.Socket, wg *sync.WaitGroup, ch chan<-TransInfo, logFn func(...interface{})) { var data []byte var key int for { select { case <-ctx.Done(): + logFn("recvRoutine ctx.Done") wg.Done() return default: @@ -75,6 +76,8 @@ data = []byte{} key = 0 } + } else { + time.Sleep(10 * time.Millisecond) } } } @@ -195,7 +198,7 @@ sockReply.ForceBind(int(regR.ReplyKey)) handle.wg.Add(1) //serve server reply - go recvRoutine(ctx, sockReply, handle.wg, handle.chReply) + go recvRoutine(ctx, sockReply, handle.wg, handle.chReply, handle.printLog) handle.sockRep = &sockServer{ sock: sockReply, info: &ri.Proc, @@ -224,7 +227,7 @@ //鍚姩璁㈤槄淇℃伅鎺ユ敹 handle.wg.Add(1) - go recvRoutine(ctx, sockSub, handle.wg, handle.chSub) + go recvRoutine(ctx, sockSub, handle.wg, handle.chSub, handle.printLog) handle.sockSub = &sockClient{ sock: sockSub, peer: -1, -- Gitblit v1.8.0