diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-17 16:16:18 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-17 16:16:18 +0200 |
commit | c5d7efc2467abb6cd8365c83fae68da6924c17f2 (patch) | |
tree | 0324219cf4979a87fc45fc575e26f7058b0a196f /src/index.go | |
parent | dd4da93749fd9a8a231942a6b75ad137cc308e02 (diff) | |
download | wireguard-go-c5d7efc2467abb6cd8365c83fae68da6924c17f2.tar.gz wireguard-go-c5d7efc2467abb6cd8365c83fae68da6924c17f2.zip |
Fixed deadlock in index.go
Diffstat (limited to 'src/index.go')
-rw-r--r-- | src/index.go | 6 |
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] |