mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-29 03:51:31 +00:00
Fix payload not return to pool
This commit is contained in:
parent
5a1ddea100
commit
4fb227ed86
|
@ -178,6 +178,7 @@ func CopyEarlyConn(ctx context.Context, conn net.Conn, serverConn net.Conn) erro
|
||||||
payload := cachedReader.ReadCached()
|
payload := cachedReader.ReadCached()
|
||||||
if payload != nil && !payload.IsEmpty() {
|
if payload != nil && !payload.IsEmpty() {
|
||||||
_, err := serverConn.Write(payload.Bytes())
|
_, err := serverConn.Write(payload.Bytes())
|
||||||
|
payload.Release()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -189,10 +190,12 @@ func CopyEarlyConn(ctx context.Context, conn net.Conn, serverConn net.Conn) erro
|
||||||
err := conn.SetReadDeadline(time.Now().Add(C.ReadPayloadTimeout))
|
err := conn.SetReadDeadline(time.Now().Add(C.ReadPayloadTimeout))
|
||||||
if err != os.ErrInvalid {
|
if err != os.ErrInvalid {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
payload.Release()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = payload.ReadOnceFrom(conn)
|
_, err = payload.ReadOnceFrom(conn)
|
||||||
if err != nil && !E.IsTimeout(err) {
|
if err != nil && !E.IsTimeout(err) {
|
||||||
|
payload.Release()
|
||||||
return E.Cause(err, "read payload")
|
return E.Cause(err, "read payload")
|
||||||
}
|
}
|
||||||
err = conn.SetReadDeadline(time.Time{})
|
err = conn.SetReadDeadline(time.Time{})
|
||||||
|
@ -202,10 +205,10 @@ func CopyEarlyConn(ctx context.Context, conn net.Conn, serverConn net.Conn) erro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = serverConn.Write(payload.Bytes())
|
_, err = serverConn.Write(payload.Bytes())
|
||||||
|
payload.Release()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return N.ReportHandshakeFailure(conn, err)
|
return N.ReportHandshakeFailure(conn, err)
|
||||||
}
|
}
|
||||||
payload.Release()
|
|
||||||
}
|
}
|
||||||
return bufio.CopyConn(ctx, conn, serverConn)
|
return bufio.CopyConn(ctx, conn, serverConn)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue