Ver Fonte

fix a bug in udp hub

Darien Raymond há 8 anos atrás
pai
commit
48639ddb98
1 ficheiros alterados com 8 adições e 1 exclusões
  1. 8 1
      transport/internet/udp/hub.go

+ 8 - 1
transport/internet/udp/hub.go

@@ -130,7 +130,14 @@ func (v *Hub) WriteTo(payload []byte, dest v2net.Destination) (int, error) {
 
 func (v *Hub) start(ctx context.Context) {
 	oobBytes := make([]byte, 256)
-	for range ctx.Done() {
+L:
+	for {
+		select {
+		case <-ctx.Done():
+			break L
+		default:
+		}
+
 		buffer := buf.NewSmall()
 		var noob int
 		var addr *net.UDPAddr