diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-17 17:25:45 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-17 17:25:58 +0100 |
commit | fa399a91d5da9874cbf248e00db8dbd87b587e91 (patch) | |
tree | 8aaca42f4a3cc11666c12d5077e8ed5ac35200a8 /src/device.go | |
parent | e1227d3af480eae72639cde842b4d538c58936dc (diff) |
Ported remaining netns.sh
- Ported remaining netns.sh tests
- Begin work on generic implementation of bind interface
Diffstat (limited to 'src/device.go')
-rw-r--r-- | src/device.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/device.go b/src/device.go index 429ee46..0085cee 100644 --- a/src/device.go +++ b/src/device.go @@ -8,8 +8,9 @@ import ( ) type Device struct { - log *Logger // collection of loggers for levels - idCounter uint // for assigning debug ids to peers + closed AtomicBool // device is closed? (acting as guard) + log *Logger // collection of loggers for levels + idCounter uint // for assigning debug ids to peers fwMark uint32 tun struct { device TUNDevice @@ -203,6 +204,9 @@ func (device *Device) RemoveAllPeers() { } func (device *Device) Close() { + if device.closed.Swap(true) { + return + } device.log.Info.Println("Closing device") device.RemoveAllPeers() close(device.signal.stop) |