Bläddra i källkod

Move goroutine one level above.

V2Ray 10 år sedan
förälder
incheckning
055c8f1833
3 ändrade filer med 8 tillägg och 12 borttagningar
  1. 1 2
      point.go
  2. 6 8
      proxy/freedom/freedom.go
  3. 1 2
      proxy/vmess/vmessout.go

+ 1 - 2
point.go

@@ -97,7 +97,6 @@ func (vp *Point) Start() error {
 
 func (p *Point) DispatchToOutbound(packet v2net.Packet) InboundRay {
 	ray := NewRay()
-	// TODO: handle error
-	p.och.Dispatch(packet, ray)
+	go p.och.Dispatch(packet, ray)
 	return ray
 }

+ 6 - 8
proxy/freedom/freedom.go

@@ -46,14 +46,12 @@ func (vconn *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray core.Outb
 
 	go dumpOutput(conn, output, &readMutex, firstPacket.Destination().IsUDP())
 
-	go func() {
-		writeMutex.Lock()
-		if tcpConn, ok := conn.(*net.TCPConn); ok {
-			tcpConn.CloseWrite()
-		}
-		readMutex.Lock()
-		conn.Close()
-	}()
+	writeMutex.Lock()
+	if tcpConn, ok := conn.(*net.TCPConn); ok {
+		tcpConn.CloseWrite()
+	}
+	readMutex.Lock()
+	conn.Close()
 
 	return nil
 }

+ 1 - 2
proxy/vmess/vmessout.go

@@ -88,8 +88,7 @@ func (handler *VMessOutboundHandler) Dispatch(firstPacket v2net.Packet, ray core
 	request.RequestKey = buffer[16:32]
 	request.ResponseHeader = buffer[32:]
 
-	go startCommunicate(request, vNextAddress, ray, firstPacket)
-	return nil
+	return startCommunicate(request, vNextAddress, ray, firstPacket)
 }
 
 func startCommunicate(request *protocol.VMessRequest, dest v2net.Destination, ray core.OutboundRay, firstPacket v2net.Packet) error {