mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-04 20:37:37 +03:00
Fix grpclite memory leak
Co-authored-by: talrasha007 <talrasha007@gmail.om>
This commit is contained in:
parent
63e6c85f6f
commit
2d73ef511d
1 changed files with 7 additions and 4 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
var _ net.Conn = (*GunConn)(nil)
|
var _ net.Conn = (*GunConn)(nil)
|
||||||
|
|
||||||
type GunConn struct {
|
type GunConn struct {
|
||||||
|
rawReader io.Reader
|
||||||
reader *std_bufio.Reader
|
reader *std_bufio.Reader
|
||||||
writer io.Writer
|
writer io.Writer
|
||||||
flusher http.Flusher
|
flusher http.Flusher
|
||||||
|
@ -31,9 +32,10 @@ type GunConn struct {
|
||||||
|
|
||||||
func newGunConn(reader io.Reader, writer io.Writer, flusher http.Flusher) *GunConn {
|
func newGunConn(reader io.Reader, writer io.Writer, flusher http.Flusher) *GunConn {
|
||||||
return &GunConn{
|
return &GunConn{
|
||||||
reader: std_bufio.NewReader(reader),
|
rawReader: reader,
|
||||||
writer: writer,
|
reader: std_bufio.NewReader(reader),
|
||||||
flusher: flusher,
|
writer: writer,
|
||||||
|
flusher: flusher,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ func newLateGunConn(writer io.Writer) *GunConn {
|
||||||
|
|
||||||
func (c *GunConn) setup(reader io.Reader, err error) {
|
func (c *GunConn) setup(reader io.Reader, err error) {
|
||||||
if reader != nil {
|
if reader != nil {
|
||||||
|
c.rawReader = reader
|
||||||
c.reader = std_bufio.NewReader(reader)
|
c.reader = std_bufio.NewReader(reader)
|
||||||
}
|
}
|
||||||
c.err = err
|
c.err = err
|
||||||
|
@ -138,7 +141,7 @@ func (c *GunConn) FrontHeadroom() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GunConn) Close() error {
|
func (c *GunConn) Close() error {
|
||||||
return common.Close(c.reader, c.writer)
|
return common.Close(c.rawReader, c.writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GunConn) LocalAddr() net.Addr {
|
func (c *GunConn) LocalAddr() net.Addr {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue