From 02e419ed8af63294fb0d9015d5c77b78fe92709e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 29 Mar 2021 12:36:09 -0700 Subject: [PATCH] device: rename unsafeCloseBind to closeBindLocked And document a bit. This name is more idiomatic. Signed-off-by: Josh Bleecher Snyder --- device/device.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/device/device.go b/device/device.go index 3b8770b..1e32db6 100644 --- a/device/device.go +++ b/device/device.go @@ -400,7 +400,9 @@ func (device *Device) SendKeepalivesToPeersWithCurrentKeypair() { device.peers.RUnlock() } -func unsafeCloseBind(device *Device) error { +// closeBindLocked closes the device's net.bind. +// The caller must hold the net mutex. +func closeBindLocked(device *Device) error { var err error netc := &device.net if netc.netlinkCancel != nil { @@ -455,7 +457,7 @@ func (device *Device) BindUpdate() error { defer device.net.Unlock() // close existing sockets - if err := unsafeCloseBind(device); err != nil { + if err := closeBindLocked(device); err != nil { return err } @@ -511,7 +513,7 @@ func (device *Device) BindUpdate() error { func (device *Device) BindClose() error { device.net.Lock() - err := unsafeCloseBind(device) + err := closeBindLocked(device) device.net.Unlock() return err }