Cleanup
This commit is contained in:
		| @@ -5,7 +5,6 @@ import ( | ||||
| 	"log" | ||||
| 	"net" | ||||
| 	"net/netip" | ||||
| 	"runtime/debug" | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| @@ -21,9 +20,11 @@ func newConnWriter(conn *net.UDPConn) *connWriter { | ||||
| } | ||||
|  | ||||
| func (w *connWriter) WriteTo(packet []byte, addr netip.AddrPort) { | ||||
| 	// Even though a conn is safe for concurrent use, it turns out that a mutex | ||||
| 	// in Go is more fair when there's contention. Without this lock, control | ||||
| 	// packets may fail to be sent in a timely manner causing timeouts. | ||||
| 	w.lock.Lock() | ||||
| 	if _, err := w.conn.WriteToUDPAddrPort(packet, addr); err != nil { | ||||
| 		debug.PrintStack() | ||||
| 		log.Fatalf("Failed to write to UDP port: %v", err) | ||||
| 	} | ||||
| 	w.lock.Unlock() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user