Fixed deadlock in index.go
This commit is contained in:
parent
dd4da93749
commit
c5d7efc246
8 changed files with 194 additions and 152 deletions
|
|
@ -6,8 +6,6 @@ import (
|
|||
)
|
||||
|
||||
/* Index=0 is reserved for unset indecies
|
||||
*
|
||||
* TODO: Rethink map[id] -> peer VS map[id] -> handshake and handshake <ref> 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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue