Fix close pipe

This commit is contained in:
世界 2022-05-30 19:45:20 +08:00
parent f0b58d9ee0
commit 91ce752405
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 17 additions and 30 deletions

View file

@ -1,11 +1,11 @@
package shadowsocks_2022
import (
"errors"
"io"
B "github.com/sagernet/sing/common/buf"
M "github.com/sagernet/sing/common/metadata"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/net"
)
@ -47,9 +47,6 @@ type pipeConnWrapper struct {
}
func (w *pipeConnWrapper) Close() error {
common.Interrupt(w.R)
common.Interrupt(w.W)
common.Close(w.Conn)
return nil
}
@ -136,8 +133,13 @@ func (w *packetConnWrapper) WritePacket(buffer *B.Buffer, destination M.Socksadd
}
func (w *packetConnWrapper) Close() error {
common.Interrupt(w.Reader)
common.Close(w.Conn)
buf.ReleaseMulti(w.cached)
return nil
}
func returnError(err error) error {
if errors.Is(err, io.EOF) {
return nil
}
return err
}