zhangmeng
2020-08-20 57e6102fc10909d6e13a4efe463a915c0e47e2ab
bug fixed
1个文件已修改
20 ■■■■ 已修改文件
library.go 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
library.go
@@ -66,7 +66,12 @@
    chReply chan TransInfo
}
func recvRoutine(ctx context.Context, sock *DgramSocket, wg *sync.WaitGroup, ch chan<- TransInfo) {
const (
    routineSub   = "sub"
    routineReply = "reply"
)
func recvRoutine(ctx context.Context, sock *DgramSocket, wg *sync.WaitGroup, ch chan<- TransInfo, id string) {
    for {
        select {
        case <-ctx.Done():
@@ -80,6 +85,10 @@
                        info: &info,
                        port: peer,
                    }
                    // if id == routineReply {
                    //     fmt.Println("repley server recv:", info)
                    // }
                }
            } else {
                // time.Sleep(10 * time.Millisecond)
@@ -152,7 +161,7 @@
    // 启动接收线程
    wg.Add(1)
    go recvRoutine(ctx, sockReply, wg, chSub)
    go recvRoutine(ctx, sockReply, wg, chReply, routineReply)
    repS := &sockServer{
        sock: sockReply,
        info: info.ProcInfo,
@@ -179,7 +188,7 @@
    }
    // 启动接收线程
    wg.Add(1)
    go recvRoutine(ctx, sockSub, wg, chSub)
    go recvRoutine(ctx, sockSub, wg, chSub, routineSub)
    subC := &sockClient{
        sock: sockSub,
        peer: -1,
@@ -360,6 +369,11 @@
                        return nil
                    }
                }
            } else {
                try++
                if try > count {
                    return nil
                }
            }
        }
    }