device: fix comment typo and shorten state.mu.Lock to state.Lock

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2021-02-09 15:35:43 +01:00
parent 02138f1f81
commit a816e8511e
2 changed files with 12 additions and 13 deletions

View File

@@ -52,7 +52,7 @@ type Peer struct {
}
state struct {
mu sync.Mutex // protects against concurrent Start/Stop
sync.Mutex // protects against concurrent Start/Stop
}
queue struct {
@@ -161,8 +161,8 @@ func (peer *Peer) Start() {
}
// prevent simultaneous start/stop operations
peer.state.mu.Lock()
defer peer.state.mu.Unlock()
peer.state.Lock()
defer peer.state.Unlock()
if peer.isRunning.Get() {
return
@@ -242,8 +242,8 @@ func (peer *Peer) ExpireCurrentKeypairs() {
}
func (peer *Peer) Stop() {
peer.state.mu.Lock()
defer peer.state.mu.Unlock()
peer.state.Lock()
defer peer.state.Unlock()
if !peer.isRunning.Swap(false) {
return