1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-22 21:49:10 -04:00

fix pipe closing logic for inbound proxies.

This commit is contained in:
Darien Raymond
2018-05-27 11:42:01 +02:00
parent cad07c3a83
commit 7fa4bb434b
10 changed files with 16 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/functions"
"v2ray.com/core/common/log"
"v2ray.com/core/common/net"
http_proto "v2ray.com/core/common/protocol/http"
@@ -192,7 +193,6 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
}
requestDone := func() error {
defer common.Close(link.Writer)
defer timer.SetTimeout(s.policy().Timeouts.DownlinkOnly)
v2reader := buf.NewReader(conn)
@@ -210,7 +210,7 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
return nil
}
if err := signal.ExecuteParallel(ctx, requestDone, responseDone); err != nil {
if err := signal.ExecuteParallel(ctx, functions.OnSuccess(requestDone, functions.Close(link.Writer)), responseDone); err != nil {
pipe.CloseError(link.Reader)
pipe.CloseError(link.Writer)
return newError("connection ends").Base(err)