Skip to content

Commit 86bab5e

Browse files
authored
fix(*) fix cpu , memory (#19)
* Fix the problem of CPU spike %100 due to dead loop caused by incorrect judgment of Read result. * Fix for growing cache that could lead to memory overflows
1 parent f63a3c0 commit 86bab5e

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module github.com/yomorun/yomo
33
go 1.14
44

55
require (
6-
github.com/10cella/yomo-json-codec v0.2.0
6+
github.com/10cella/yomo-json-codec v0.2.1
77
github.com/lucas-clemente/quic-go v0.17.1
88
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ github.com/10cella/yomo-json-codec v0.1.0 h1:EE33np1AP3y67sbgZqWH4IroPtJubWQCoGz
1313
github.com/10cella/yomo-json-codec v0.1.0/go.mod h1:9rwfqlpW8iZ9Ki5/frJsO2fBSl9x24QB16jloj7YPCc=
1414
github.com/10cella/yomo-json-codec v0.2.0 h1:VCFrpoVeYX6AnVQcYaIKcPbMKNERx/ZKno7Ejuiudrc=
1515
github.com/10cella/yomo-json-codec v0.2.0/go.mod h1:oApqc2PnZohrtlVJ3T1Knou9Ap9mcCJW1i3xiRtvF7c=
16+
github.com/10cella/yomo-json-codec v0.2.1 h1:cWh5TovVPlrOJKkjTVuCkpQ4rj1QoY2ANHCD7afB+6M=
17+
github.com/10cella/yomo-json-codec v0.2.1/go.mod h1:oApqc2PnZohrtlVJ3T1Knou9Ap9mcCJW1i3xiRtvF7c=
1618
github.com/10cella/yomo-txtkv-codec v1.0.5 h1:rVdtBcsff3RG3BEq7AHq2WvNiGDF6IEKlTiplypfX+c=
1719
github.com/10cella/yomo-txtkv-codec v1.0.5/go.mod h1:nBfcD3qVq6kkSRHOgSUxK1+gMRoXI0obLF+b1eiyCtM=
1820
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

pkg/util/quic.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,22 @@ func (w YomoFrameworkStreamWriter) Write(b []byte) (int, error) {
4040
for {
4141
value, err = w.Codec.Read(w.Plugin.Mold())
4242
if err != nil {
43+
log.Panic(err)
4344
break
4445
}
4546

46-
if value != nil {
47-
result, err = w.Plugin.Handle(value)
48-
if err != nil {
49-
log.Fatal(err)
50-
}
51-
//fmt.Println("handle result:", result)
52-
w.Codec.Write(w.Writer, result, w.Plugin.Mold()) // nolint
47+
if value == nil {
48+
w.Codec.Refresh(w.Writer) // nolint
5349
break
5450
}
5551

56-
//if len(value.(string)) > 0 {
57-
// result, err = w.Plugin.Handle(value)
58-
// if err != nil {
59-
// log.Fatal(err)
60-
// }
61-
// if result == nil {
62-
// result = ""
63-
// }
64-
// w.Codec.Write(w.Writer, fmt.Sprint(result)) // nolint
52+
//if value != nil {
53+
result, err = w.Plugin.Handle(value)
54+
if err != nil {
55+
log.Fatal(err)
56+
}
57+
//fmt.Println("handle result:", result)
58+
w.Codec.Write(w.Writer, result, w.Plugin.Mold()) // nolint
6559
// break
6660
//}
6761
}

0 commit comments

Comments
 (0)