aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-17 16:16:18 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-17 16:16:18 +0200
commitc5d7efc2467abb6cd8365c83fae68da6924c17f2 (patch)
tree0324219cf4979a87fc45fc575e26f7058b0a196f /src/index.go
parentAdded padding (diff)
downloadwireguard-go-c5d7efc2467abb6cd8365c83fae68da6924c17f2.tar.xz
wireguard-go-c5d7efc2467abb6cd8365c83fae68da6924c17f2.zip
Fixed deadlock in index.go
Diffstat (limited to 'src/index.go')
-rw-r--r--src/index.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/index.go b/src/index.go
index 59e2079..44b4974 100644
--- a/src/index.go
+++ b/src/index.go
@@ -7,8 +7,6 @@ import (
/* Index=0 is reserved for unset indecies
*
- * TODO: Rethink map[id] -> peer VS map[id] -> handshake and handshake <ref> peer
- *
*/
type IndexTableEntry struct {
@@ -72,12 +70,12 @@ func (table *IndexTable) NewIndex(peer *Peer) (uint32, error) {
table.mutex.RLock()
_, ok := table.table[index]
+ table.mutex.RUnlock()
if ok {
continue
}
- table.mutex.RUnlock()
- // replace index
+ // map index to handshake
table.mutex.Lock()
_, found := table.table[index]