Skip to content

Commit

Permalink
fix(*) fix cpu , memory (#19)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chenjunbiao authored Jul 16, 2020
1 parent f63a3c0 commit 86bab5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/yomorun/yomo
go 1.14

require (
github.com/10cella/yomo-json-codec v0.2.0
github.com/10cella/yomo-json-codec v0.2.1
github.com/lucas-clemente/quic-go v0.17.1
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/10cella/yomo-json-codec v0.1.0 h1:EE33np1AP3y67sbgZqWH4IroPtJubWQCoGz
github.com/10cella/yomo-json-codec v0.1.0/go.mod h1:9rwfqlpW8iZ9Ki5/frJsO2fBSl9x24QB16jloj7YPCc=
github.com/10cella/yomo-json-codec v0.2.0 h1:VCFrpoVeYX6AnVQcYaIKcPbMKNERx/ZKno7Ejuiudrc=
github.com/10cella/yomo-json-codec v0.2.0/go.mod h1:oApqc2PnZohrtlVJ3T1Knou9Ap9mcCJW1i3xiRtvF7c=
github.com/10cella/yomo-json-codec v0.2.1 h1:cWh5TovVPlrOJKkjTVuCkpQ4rj1QoY2ANHCD7afB+6M=
github.com/10cella/yomo-json-codec v0.2.1/go.mod h1:oApqc2PnZohrtlVJ3T1Knou9Ap9mcCJW1i3xiRtvF7c=
github.com/10cella/yomo-txtkv-codec v1.0.5 h1:rVdtBcsff3RG3BEq7AHq2WvNiGDF6IEKlTiplypfX+c=
github.com/10cella/yomo-txtkv-codec v1.0.5/go.mod h1:nBfcD3qVq6kkSRHOgSUxK1+gMRoXI0obLF+b1eiyCtM=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down
26 changes: 10 additions & 16 deletions pkg/util/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,22 @@ func (w YomoFrameworkStreamWriter) Write(b []byte) (int, error) {
for {
value, err = w.Codec.Read(w.Plugin.Mold())
if err != nil {
log.Panic(err)
break
}

if value != nil {
result, err = w.Plugin.Handle(value)
if err != nil {
log.Fatal(err)
}
//fmt.Println("handle result:", result)
w.Codec.Write(w.Writer, result, w.Plugin.Mold()) // nolint
if value == nil {
w.Codec.Refresh(w.Writer) // nolint
break
}

//if len(value.(string)) > 0 {
// result, err = w.Plugin.Handle(value)
// if err != nil {
// log.Fatal(err)
// }
// if result == nil {
// result = ""
// }
// w.Codec.Write(w.Writer, fmt.Sprint(result)) // nolint
//if value != nil {
result, err = w.Plugin.Handle(value)
if err != nil {
log.Fatal(err)
}
//fmt.Println("handle result:", result)
w.Codec.Write(w.Writer, result, w.Plugin.Mold()) // nolint
// break
//}
}
Expand Down

0 comments on commit 86bab5e

Please sign in to comment.