This commit is contained in:
黄思敏 2022-08-26 10:54:43 +08:00
parent 10c5e7779d
commit b9fa5637af

View File

@ -13,7 +13,6 @@ import (
"sync/atomic"
"time"
"github.com/klauspost/compress/zstd"
"github.com/songgao/packets/ethernet"
"github.com/songgao/water"
"github.com/songgao/water/waterutil"
@ -85,14 +84,14 @@ func (cli *RPCClient) run() {
}
// zstd compress
zenc, err := zstd.NewWriter(buf)
if err != nil {
log.Panic(err)
}
err = zenc.Flush()
if err != nil {
log.Println(err)
}
// zenc, err := zstd.NewWriter(buf)
// if err != nil {
// log.Panic(err)
// }
// err = zenc.Flush()
// if err != nil {
// log.Println(err)
// }
log.Printf("%v %d", cliBuffer, len(buf.Bytes()))
// 发到对面的网卡
@ -236,7 +235,7 @@ func (nc *NetCard) runRead() {
func (nc *NetCard) runWrite() {
var ifce *water.Interface = nc.ifce
var err error
var buf = bytes.NewBuffer(nil)
for wframe := range nc.FrameChan {
@ -244,11 +243,11 @@ func (nc *NetCard) runWrite() {
buf.Reset()
buf.Write(wframe)
zdec, err := zstd.NewReader(buf)
if err != nil {
log.Panic(err)
}
zdec.Close()
// zdec, err := zstd.NewReader(buf)
// if err != nil {
// log.Panic(err)
// }
// zdec.Close()
dec := gob.NewDecoder(buf)
var bufs [][]byte