v2ray 9 лет назад
Родитель
Сommit
67db5830be
3 измененных файлов с 5 добавлено и 2 удалено
  1. 1 0
      proxy/freedom/freedom.go
  2. 1 1
      proxy/shadowsocks/shadowsocks.go
  3. 3 1
      proxy/vmess/inbound/inbound.go

+ 1 - 0
proxy/freedom/freedom.go

@@ -68,6 +68,7 @@ func (this *FreedomConnection) Dispatch(destination v2net.Destination, payload *
 		defer v2reader.Release()
 
 		v2io.Pipe(v2reader, output)
+		ray.OutboundOutput().Close()
 	}()
 
 	writeMutex.Lock()

+ 1 - 1
proxy/shadowsocks/shadowsocks.go

@@ -205,6 +205,7 @@ func (this *Shadowsocks) handleConnection(conn *hub.Connection) {
 	log.Info("Shadowsocks: Tunnelling request to ", dest)
 
 	ray := this.packetDispatcher.DispatchToOutbound(dest)
+	defer ray.InboundOutput().Release()
 
 	var writeFinish sync.Mutex
 	writeFinish.Lock()
@@ -227,7 +228,6 @@ func (this *Shadowsocks) handleConnection(conn *hub.Connection) {
 			v2writer := v2io.NewAdaptiveWriter(writer)
 
 			v2io.Pipe(ray.InboundOutput(), v2writer)
-			ray.InboundOutput().Release()
 			writer.Release()
 			v2writer.Release()
 		}

+ 3 - 1
proxy/vmess/inbound/inbound.go

@@ -139,6 +139,9 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
 	ray := this.packetDispatcher.DispatchToOutbound(request.Destination())
 	input := ray.InboundInput()
 	output := ray.InboundOutput()
+	defer input.Close()
+	defer output.Release()
+
 	var readFinish, writeFinish sync.Mutex
 	readFinish.Lock()
 	writeFinish.Lock()
@@ -189,7 +192,6 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
 			if request.Option.IsChunkStream() {
 				writer.Write(alloc.NewSmallBuffer().Clear())
 			}
-			output.Release()
 			writer.Release()
 			finish.Unlock()
 		}(&writeFinish)