Skip to content

Commit 6f895be

Browse files
committed
conn: move booleans to bottom of StdNetBind struct
This results in a more compact structure. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 6a07b2a commit 6f895be

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Diff for: conn/bind_std.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ var (
2929
// methods for sending and receiving multiple datagrams per-syscall. See the
3030
// proposal in https://github.com/golang/go/issues/45886#issuecomment-1218301564.
3131
type StdNetBind struct {
32-
mu sync.Mutex // protects following fields
33-
ipv4 *net.UDPConn
34-
ipv6 *net.UDPConn
35-
blackhole4 bool
36-
blackhole6 bool
37-
ipv4PC *ipv4.PacketConn // will be nil on non-Linux
38-
ipv6PC *ipv6.PacketConn // will be nil on non-Linux
39-
40-
udpAddrPool sync.Pool // following fields are not guarded by mu
32+
mu sync.Mutex // protects all fields except as specified
33+
ipv4 *net.UDPConn
34+
ipv6 *net.UDPConn
35+
ipv4PC *ipv4.PacketConn // will be nil on non-Linux
36+
ipv6PC *ipv6.PacketConn // will be nil on non-Linux
37+
38+
// these three fields are not guarded by mu
39+
udpAddrPool sync.Pool
4140
ipv4MsgsPool sync.Pool
4241
ipv6MsgsPool sync.Pool
42+
43+
blackhole4 bool
44+
blackhole6 bool
4345
}
4446

4547
func NewStdNetBind() Bind {

0 commit comments

Comments
 (0)