优化byte内存池

This commit is contained in:
bjdgyc
2021-07-19 12:30:20 +08:00
parent ea4dda0fca
commit 8ff77626d0
5 changed files with 29 additions and 23 deletions

View File

@@ -101,7 +101,8 @@ func tapWrite(ifce *water.Interface, cSess *sessdata.ConnSession) {
}
// var frame ethernet.Frame
frame = getByteFull()
fb := getByteFull()
frame = *fb
switch payload.LType {
default:
// log.Println(payload)
@@ -153,7 +154,7 @@ func tapWrite(ifce *water.Interface, cSess *sessdata.ConnSession) {
return
}
putByte(frame)
putByte(fb)
putPayload(payload)
}
}
@@ -174,7 +175,8 @@ func tapRead(ifce *water.Interface, cSess *sessdata.ConnSession) {
for {
// var frame ethernet.Frame
// frame.Resize(BufferSize)
frame = getByteFull()
fb := getByteFull()
frame = *fb
n, err = ifce.Read(frame)
if err != nil {
base.Error("tap Read err", n, err)
@@ -247,6 +249,6 @@ func tapRead(ifce *water.Interface, cSess *sessdata.ConnSession) {
}
putByte(frame)
putByte(fb)
}
}