]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
conn: move booleans to bottom of StdNetBind struct
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 24 Mar 2023 15:21:46 +0000 (16:21 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 24 Mar 2023 16:05:07 +0000 (17:05 +0100)
This results in a more compact structure.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
conn/bind_std.go

index ab2bd85efc8069f931ec46dbc3b33e391ad64cb4..69789b33fe65b51d9652513c35d937b44235976a 100644 (file)
@@ -29,17 +29,19 @@ var (
 // methods for sending and receiving multiple datagrams per-syscall. See the
 // proposal in https://github.com/golang/go/issues/45886#issuecomment-1218301564.
 type StdNetBind struct {
-       mu         sync.Mutex // protects following fields
-       ipv4       *net.UDPConn
-       ipv6       *net.UDPConn
-       blackhole4 bool
-       blackhole6 bool
-       ipv4PC     *ipv4.PacketConn // will be nil on non-Linux
-       ipv6PC     *ipv6.PacketConn // will be nil on non-Linux
-
-       udpAddrPool  sync.Pool // following fields are not guarded by mu
+       mu     sync.Mutex // protects all fields except as specified
+       ipv4   *net.UDPConn
+       ipv6   *net.UDPConn
+       ipv4PC *ipv4.PacketConn // will be nil on non-Linux
+       ipv6PC *ipv6.PacketConn // will be nil on non-Linux
+
+       // these three fields are not guarded by mu
+       udpAddrPool  sync.Pool
        ipv4MsgsPool sync.Pool
        ipv6MsgsPool sync.Pool
+
+       blackhole4 bool
+       blackhole6 bool
 }
 
 func NewStdNetBind() Bind {