aboutsummaryrefslogtreecommitdiff
path: root/src/device.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-11 23:26:44 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-11 23:26:44 +0100
commit566269275ed97812ec909b10ec77c7c037d9e2ea (patch)
treea5cf35234f15728dee85918088502ad5653a9513 /src/device.go
parent892276aa64ca9b14d2e96186b83145ab2f5ce25a (diff)
downloadwireguard-go-566269275ed97812ec909b10ec77c7c037d9e2ea.tar.gz
wireguard-go-566269275ed97812ec909b10ec77c7c037d9e2ea.zip
Fixed blocking reader on closed socket
Diffstat (limited to 'src/device.go')
-rw-r--r--src/device.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/device.go b/src/device.go
index a348c68..033a387 100644
--- a/src/device.go
+++ b/src/device.go
@@ -23,10 +23,10 @@ type Device struct {
}
net struct {
mutex sync.RWMutex
- bind UDPBind // bind interface
- port uint16 // listening port
- fwmark uint32 // mark value (0 = disabled)
- update *sync.Cond // the bind was updated
+ bind UDPBind // bind interface
+ port uint16 // listening port
+ fwmark uint32 // mark value (0 = disabled)
+ update sync.WaitGroup // the bind was updated (acting as a barrier)
}
mutex sync.RWMutex
privateKey NoisePrivateKey
@@ -167,7 +167,7 @@ func NewDevice(tun TUNDevice, logLevel int) *Device {
device.net.port = 0
device.net.bind = nil
- device.net.update = sync.NewCond(&device.net.mutex)
+ device.net.update.Add(1)
// start workers
@@ -209,9 +209,11 @@ func (device *Device) RemoveAllPeers() {
}
func (device *Device) Close() {
+ device.log.Info.Println("Closing device")
device.RemoveAllPeers()
close(device.signal.stop)
CloseUDPListener(device)
+ device.tun.device.Close()
}
func (device *Device) WaitChannel() chan struct{} {