Skip to content

Commit

Permalink
fix: call conn.release method in ext.ReleaseBodystream
Browse files Browse the repository at this point in the history
  • Loading branch information
Duslia committed Dec 31, 2024
1 parent 7d63572 commit de8625b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/protocol/http1/ext/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ func (rs *bodyStream) skipRest() error {
if err != nil {
return err
}
// After Skip, the buffer needs to be released to prevent OOM if there are too much data on conn.
err = rs.reader.Release()
if err != nil {
return err
}

}
}
// max value of pSize is 8193, it's safe.
Expand Down Expand Up @@ -300,7 +306,15 @@ func (rs *bodyStream) skipRest() error {
if skip > needSkipLen {
skip = needSkipLen
}
rs.reader.Skip(skip)
err := rs.reader.Skip(skip)
if err != nil {
return err
}
// After Skip, the buffer needs to be released to prevent OOM if there are too much data on conn.
err = rs.reader.Release()
if err != nil {
return err
}
needSkipLen -= skip
if needSkipLen == 0 {
return nil
Expand Down

0 comments on commit de8625b

Please sign in to comment.