From 4135e6978ae74bdc398899437f682bdf9eac8039 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 16 Jan 2023 12:28:30 +0800 Subject: [PATCH] fix: add ReaderReplaceable to BufferedConn, avoid buffered data lost --- common/net/bufconn.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/net/bufconn.go b/common/net/bufconn.go index 9f1dda2b..ba0ca026 100644 --- a/common/net/bufconn.go +++ b/common/net/bufconn.go @@ -58,3 +58,10 @@ func (c *BufferedConn) ReadBuffer(buffer *buf.Buffer) (err error) { func (c *BufferedConn) Upstream() any { return c.ExtendedConn } + +func (c *BufferedConn) ReaderReplaceable() bool { + if c.r.Buffered() > 0 { + return false + } + return true +}