删除某个cancel

This commit is contained in:
黄思敏 2022-08-25 12:02:49 +08:00
parent eead5b9d5f
commit 0c64d3e838

8
tap.go
View File

@ -12,7 +12,6 @@ import (
"github.com/songgao/packets/ethernet"
"github.com/songgao/water"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"
)
@ -40,10 +39,6 @@ func (cli *RPCClient) connect() {
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
log.Println(conn.WaitForStateChange(ctx, connectivity.Idle))
cli.conn = conn
go cli.run()
time.Sleep(time.Millisecond)
@ -59,6 +54,7 @@ func (cli *RPCClient) run() {
}()
c := gen.NewFrameServiceClient(cli.conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
stream, err := c.SendFrames(ctx)
@ -144,7 +140,7 @@ func (nc *NetCard) runRead() {
framesBytes = append(framesBytes, []byte(rframe))
}
println(len(framesBytes))
log.Println(len(framesBytes))
if len(framesBytes) > 0 {
if nc.cli.conn == nil {
nc.cli.connect()