mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Change some mutexes to atomics, change conns map to pointers, sort of works but seems to deadlock very easily
This commit is contained in:
parent
62621f2960
commit
79bcfbf175
6 changed files with 81 additions and 115 deletions
|
@ -35,7 +35,7 @@ func (d *Dialer) Dial(network, address string) (Conn, error) {
|
|||
return Conn{}, err
|
||||
}
|
||||
copy(nodeID[:], dest)
|
||||
for idx := 0; idx < len; idx++ {
|
||||
for idx := 0; idx <= len; idx++ {
|
||||
nodeMask[idx/8] |= 0x80 >> byte(idx%8)
|
||||
}
|
||||
} else {
|
||||
|
@ -59,15 +59,13 @@ func (d *Dialer) Dial(network, address string) (Conn, error) {
|
|||
// NodeID parameters.
|
||||
func (d *Dialer) DialByNodeIDandMask(nodeID, nodeMask *crypto.NodeID) (Conn, error) {
|
||||
conn := Conn{
|
||||
mutex: &sync.RWMutex{},
|
||||
core: d.core,
|
||||
mutex: &sync.RWMutex{},
|
||||
nodeID: nodeID,
|
||||
nodeMask: nodeMask,
|
||||
}
|
||||
conn.core = d.core
|
||||
conn.nodeID = nodeID
|
||||
conn.nodeMask = nodeMask
|
||||
conn.core.router.doAdmin(func() {
|
||||
conn.startSearch()
|
||||
})
|
||||
conn.mutex.Lock()
|
||||
defer conn.mutex.Unlock()
|
||||
return conn, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue