新TAP测试(TODO 解析arp)

This commit is contained in:
黄思敏 2022-09-01 15:05:44 +08:00
parent 3c5bad2f67
commit f23608f496

View File

@ -63,12 +63,13 @@ func (cli *RPCClient) CheckConnect() {
}
func (cli *RPCClient) Push(frame []byte) {
cli.lock.Lock()
defer cli.lock.Unlock()
cli.Frames = append(cli.Frames, frame)
if len(cli.Frames) >= 1000 {
cli.trigger <- true
}
cli.Lock(func() bool {
cli.Frames = append(cli.Frames, frame)
if len(cli.Frames) >= 1000 {
cli.trigger <- true
}
return true
})
}
func (cli *RPCClient) run() {
@ -97,13 +98,12 @@ func (cli *RPCClient) run() {
var ticker = time.NewTicker(time.Millisecond * 20)
buf := bytes.NewBuffer(nil)
for {
select {
case <-cli.trigger:
case <-ticker.C:
}
buf.Reset()
cli.Lock(func() bool {
Compress(buf, cli.Frames)
cli.Frames = cli.Frames[:0]
@ -114,10 +114,10 @@ func (cli *RPCClient) run() {
err = stream.Send(&gen.RequestFrames{
Frames: buf.Bytes(),
})
if err != nil {
log.Panic(err)
}
buf.Reset()
}
}