summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-03-24 16:21:46 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2023-03-24 17:05:07 +0100
commit6f895be10d741d138ec240d3c53acf3afde44b6c (patch)
tree682757e3ed24118e45fce7f86978cec61b878a61
parent6a07b2a355f93fb28d37d03ae5f2c0019cdb9943 (diff)
conn: move booleans to bottom of StdNetBind struct
This results in a more compact structure. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--conn/bind_std.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/conn/bind_std.go b/conn/bind_std.go
index ab2bd85..69789b3 100644
--- a/conn/bind_std.go
+++ b/conn/bind_std.go
@@ -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 {