From c5d7efc2467abb6cd8365c83fae68da6924c17f2 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Mon, 17 Jul 2017 16:16:18 +0200 Subject: Fixed deadlock in index.go --- src/index.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/index.go') diff --git a/src/index.go b/src/index.go index 59e2079..44b4974 100644 --- a/src/index.go +++ b/src/index.go @@ -6,8 +6,6 @@ import ( ) /* Index=0 is reserved for unset indecies - * - * TODO: Rethink map[id] -> peer VS map[id] -> handshake and handshake peer * */ @@ -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] -- cgit v1.2.3