mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-02 08:20:25 +00:00
better handling error from Pipe()
This commit is contained in:
@@ -2,7 +2,6 @@ package shadowsocks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"sync"
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/common/alloc"
|
||||
@@ -113,18 +112,14 @@ func (this *Client) Dispatch(destination v2net.Destination, payload *alloc.Buffe
|
||||
return
|
||||
}
|
||||
|
||||
if err := v2io.Pipe(responseReader, ray.OutboundOutput()); err != nil {
|
||||
if err != io.EOF {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all TCP response: ", err)
|
||||
}
|
||||
if err := v2io.PipeUntilEOF(responseReader, ray.OutboundOutput()); err != nil {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all TCP response: ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
bufferedWriter.SetCached(false)
|
||||
if err := v2io.Pipe(ray.OutboundInput(), bodyWriter); err != nil {
|
||||
if err != io.EOF {
|
||||
log.Info("Shadowsocks|Client: Failed to trasnport all TCP request: ", err)
|
||||
}
|
||||
if err := v2io.PipeUntilEOF(ray.OutboundInput(), bodyWriter); err != nil {
|
||||
log.Info("Shadowsocks|Client: Failed to trasnport all TCP request: ", err)
|
||||
}
|
||||
|
||||
responseMutex.Lock()
|
||||
@@ -143,10 +138,8 @@ func (this *Client) Dispatch(destination v2net.Destination, payload *alloc.Buffe
|
||||
User: user,
|
||||
}
|
||||
|
||||
if err := v2io.Pipe(reader, ray.OutboundOutput()); err != nil {
|
||||
if err != io.EOF {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all UDP response: ", err)
|
||||
}
|
||||
if err := v2io.PipeUntilEOF(reader, ray.OutboundOutput()); err != nil {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all UDP response: ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -159,10 +152,8 @@ func (this *Client) Dispatch(destination v2net.Destination, payload *alloc.Buffe
|
||||
return errors.New("Shadowsocks|Client: Failed to write payload: " + err.Error())
|
||||
}
|
||||
}
|
||||
if err := v2io.Pipe(ray.OutboundInput(), writer); err != nil {
|
||||
if err != io.EOF {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all UDP request: ", err)
|
||||
}
|
||||
if err := v2io.PipeUntilEOF(ray.OutboundInput(), writer); err != nil {
|
||||
log.Info("Shadowsocks|Client: Failed to transport all UDP request: ", err)
|
||||
}
|
||||
|
||||
responseMutex.Lock()
|
||||
|
||||
@@ -198,11 +198,15 @@ func (this *Server) handleConnection(conn internet.Connection) {
|
||||
responseWriter.Write(payload)
|
||||
bufferedWriter.SetCached(false)
|
||||
|
||||
v2io.Pipe(ray.InboundOutput(), responseWriter)
|
||||
if err := v2io.PipeUntilEOF(ray.InboundOutput(), responseWriter); err != nil {
|
||||
log.Info("Shadowsocks|Server: Failed to transport all TCP response: ", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
v2io.Pipe(bodyReader, ray.InboundInput())
|
||||
if err := v2io.PipeUntilEOF(bodyReader, ray.InboundInput()); err != nil {
|
||||
log.Info("Shadowsocks|Server: Failed to transport all TCP request: ", err)
|
||||
}
|
||||
ray.InboundInput().Close()
|
||||
|
||||
writeFinish.Lock()
|
||||
|
||||
Reference in New Issue
Block a user