]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
conn: make StdNetBind.BatchSize() return 1 for non-Linux
authorJordan Whited <jordan@tailscale.com>
Thu, 9 Mar 2023 21:02:17 +0000 (13:02 -0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 10 Mar 2023 13:53:09 +0000 (14:53 +0100)
This commit updates StdNetBind.BatchSize() to return 1 instead of
IdealBatchSize for non-Linux platforms. Non-Linux platforms do not
yet benefit from values > 1, which only serves to increase memory
consumption.

Reviewed-by: James Tucker <james@tailscale.com>
Signed-off-by: Jordan Whited <jordan@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
conn/bind_std.go

index 0266d6bfbd97201a3b229259602bacc0b7cf5642..1ee2cef653a0b7562e1817771e9594855beda9d5 100644 (file)
@@ -272,7 +272,10 @@ func (s *StdNetBind) makeReceiveIPv6(pc *ipv6.PacketConn, conn *net.UDPConn) Rec
 // TODO: When all Binds handle IdealBatchSize, remove this dynamic function and
 // rename the IdealBatchSize constant to BatchSize.
 func (s *StdNetBind) BatchSize() int {
-       return IdealBatchSize
+       if runtime.GOOS == "linux" {
+               return IdealBatchSize
+       }
+       return 1
 }
 
 func (s *StdNetBind) Close() error {