summaryrefslogtreecommitdiffhomepage
path: root/conn.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-01-03 19:04:00 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commit89d2c5ed7a054bc05a21209d5a9c79ad7151f8f7 (patch)
treee19022fe717ddfb840599bf68e4c5a9268f8c278 /conn.go
parentdff424baf8acc4d2a5858d3947761c5090d8e640 (diff)
Extend structs rather than embed, when possible
Diffstat (limited to 'conn.go')
-rw-r--r--conn.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/conn.go b/conn.go
index c3fcf91..b19a9c2 100644
--- a/conn.go
+++ b/conn.go
@@ -78,8 +78,8 @@ func unsafeCloseBind(device *Device) error {
func (device *Device) BindSetMark(mark uint32) error {
- device.net.mutex.Lock()
- defer device.net.mutex.Unlock()
+ device.net.Lock()
+ defer device.net.Unlock()
// check if modified
@@ -98,23 +98,23 @@ func (device *Device) BindSetMark(mark uint32) error {
// clear cached source addresses
- device.peers.mutex.RLock()
+ device.peers.RLock()
for _, peer := range device.peers.keyMap {
- peer.mutex.Lock()
- defer peer.mutex.Unlock()
+ peer.Lock()
+ defer peer.Unlock()
if peer.endpoint != nil {
peer.endpoint.ClearSrc()
}
}
- device.peers.mutex.RUnlock()
+ device.peers.RUnlock()
return nil
}
func (device *Device) BindUpdate() error {
- device.net.mutex.Lock()
- defer device.net.mutex.Unlock()
+ device.net.Lock()
+ defer device.net.Unlock()
// close existing sockets
@@ -148,15 +148,15 @@ func (device *Device) BindUpdate() error {
// clear cached source addresses
- device.peers.mutex.RLock()
+ device.peers.RLock()
for _, peer := range device.peers.keyMap {
- peer.mutex.Lock()
- defer peer.mutex.Unlock()
+ peer.Lock()
+ defer peer.Unlock()
if peer.endpoint != nil {
peer.endpoint.ClearSrc()
}
}
- device.peers.mutex.RUnlock()
+ device.peers.RUnlock()
// start receiving routines
@@ -173,8 +173,8 @@ func (device *Device) BindUpdate() error {
}
func (device *Device) BindClose() error {
- device.net.mutex.Lock()
+ device.net.Lock()
err := unsafeCloseBind(device)
- device.net.mutex.Unlock()
+ device.net.Unlock()
return err
}