hotfix: close tcp conn after handle

This commit is contained in:
fengcaiwen
2025-11-15 08:36:33 +08:00
committed by naison
parent abaa9e474e
commit 903487b209
3 changed files with 12 additions and 2 deletions

View File

@@ -62,5 +62,13 @@ func (c *bufferedTCP) Run(ctx context.Context) {
func (c *bufferedTCP) Close() error {
c.closed = true
return c.Conn.Close()
for {
var buf *DatagramPacket
select {
case buf = <-c.Chan:
config.LPool.Put(buf.Data[:])
default:
return c.Conn.Close()
}
}
}

View File

@@ -41,6 +41,7 @@ func (h *gvisorTCPHandler) readFromEndpointWriteToTCPConn(ctx context.Context, c
// tun --> dispatcher
func (h *gvisorTCPHandler) readFromTCPConnWriteToEndpoint(ctx context.Context, conn net.Conn, endpoint *channel.Endpoint) {
tcpConn, _ := newGvisorUDPConnOverTCP(ctx, conn)
defer tcpConn.Close()
defer h.removeFromRouteMapTCP(ctx, conn)
for ctx.Err() == nil {