Fix: io timeout when snell v2 reuse connection (#1362)

This commit is contained in:
gVisor bot 2021-04-19 14:36:06 +08:00
parent b03a27b74c
commit 226e6d1b4d

View file

@ -3,6 +3,7 @@ package snell
import ( import (
"context" "context"
"net" "net"
"time"
"github.com/Dreamacro/clash/component/pool" "github.com/Dreamacro/clash/component/pool"
@ -61,6 +62,9 @@ func (pc *PoolConn) Write(b []byte) (int, error) {
} }
func (pc *PoolConn) Close() error { func (pc *PoolConn) Close() error {
// clash use SetReadDeadline to break bidirectional copy between client and server.
// reset it before reuse connection to avoid io timeout error.
pc.Snell.Conn.SetReadDeadline(time.Time{})
pc.pool.Put(pc.Snell) pc.pool.Put(pc.Snell)
return nil return nil
} }