Skip to content

Commit

Permalink
conn: move booleans to bottom of StdNetBind struct
Browse files Browse the repository at this point in the history
This results in a more compact structure.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
  • Loading branch information
zx2c4 committed Mar 24, 2023
1 parent 6a07b2a commit d3cb5bd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions conn/bind_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ 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
mu sync.Mutex // protects following fields
ipv4 *net.UDPConn
ipv6 *net.UDPConn
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
ipv4MsgsPool sync.Pool
ipv6MsgsPool sync.Pool

blackhole4 bool
blackhole6 bool
}

func NewStdNetBind() Bind {
Expand Down

0 comments on commit d3cb5bd

Please sign in to comment.