1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-05 08:45:22 -05:00

refine stream handling

This commit is contained in:
Darien Raymond
2017-01-04 12:34:01 +01:00
parent 723207158f
commit 49210d8362
11 changed files with 154 additions and 55 deletions

View File

@@ -35,9 +35,7 @@ func NewClient(config *ClientConfig, space app.Space, meta *proxy.OutboundHandle
}
// Dispatch implements OutboundHandler.Dispatch().
func (v *Client) Dispatch(destination v2net.Destination, payload *buf.Buffer, ray ray.OutboundRay) {
defer payload.Release()
func (v *Client) Dispatch(destination v2net.Destination, ray ray.OutboundRay) {
network := destination.Network
var server *protocol.ServerSpec
@@ -99,13 +97,6 @@ func (v *Client) Dispatch(destination v2net.Destination, payload *buf.Buffer, ra
return
}
if !payload.IsEmpty() {
if err := bodyWriter.Write(payload); err != nil {
log.Info("Shadowsocks|Client: Failed to write payload: ", err)
return
}
}
bufferedWriter.SetBuffered(false)
requestDone := signal.ExecuteAsync(func() error {
@@ -143,12 +134,6 @@ func (v *Client) Dispatch(destination v2net.Destination, payload *buf.Buffer, ra
Writer: conn,
Request: request,
}
if !payload.IsEmpty() {
if err := writer.Write(payload); err != nil {
log.Info("Shadowsocks|Client: Failed to write payload: ", err)
return
}
}
requestDone := signal.ExecuteAsync(func() error {
defer ray.OutboundInput().ForceClose()