diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-11 16:18:20 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-08-11 16:18:20 +0200 |
commit | a4eff12d7f749c992247579161c4ce9e60e2df47 (patch) | |
tree | 6032dd0a96ced8313d7199e569ab657f3ba91ca7 /src/misc.go | |
parent | cba1d6585ab9b12ae3e0897db85675ba452c3f09 (diff) | |
download | wireguard-go-a4eff12d7f749c992247579161c4ce9e60e2df47.tar.gz wireguard-go-a4eff12d7f749c992247579161c4ce9e60e2df47.zip |
Improved receive.go
- Fixed configuration listen-port semantics
- Improved receive.go code for updating listen port
- Updated under load detection, how follows the kernel space implementation
- Fixed trie bug accidentally introduced in last commit
- Added interface name to log (format still subject to change)
- Can now configure the logging level using the LOG_LEVEL variable
- Begin porting netsh.sh tests
- A number of smaller changes
Diffstat (limited to 'src/misc.go')
-rw-r--r-- | src/misc.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/misc.go b/src/misc.go index fc75c0d..d93849e 100644 --- a/src/misc.go +++ b/src/misc.go @@ -1,6 +1,7 @@ package main import ( + "sync/atomic" "time" ) @@ -8,10 +9,26 @@ import ( * (since booleans are not natively supported by sync/atomic) */ const ( - AtomicFalse = iota + AtomicFalse = int32(iota) AtomicTrue ) +type AtomicBool struct { + flag int32 +} + +func (a *AtomicBool) Get() bool { + return atomic.LoadInt32(&a.flag) == AtomicTrue +} + +func (a *AtomicBool) Set(val bool) { + flag := AtomicFalse + if val { + flag = AtomicTrue + } + atomic.StoreInt32(&a.flag, flag) +} + func min(a uint, b uint) uint { if a > b { return b |