mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Squash a whole load of races (and mutex half the world)
This commit is contained in:
parent
24281d4049
commit
f3e742a297
4 changed files with 66 additions and 20 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gologme/log"
|
||||
|
@ -273,7 +274,9 @@ func (c *Core) ListenConn() (*Listener, error) {
|
|||
// and the second parameter should contain a hexadecimal representation of the
|
||||
// target node ID.
|
||||
func (c *Core) Dial(network, address string) (Conn, error) {
|
||||
conn := Conn{}
|
||||
conn := Conn{
|
||||
sessionMutex: &sync.RWMutex{},
|
||||
}
|
||||
nodeID := crypto.NodeID{}
|
||||
nodeMask := crypto.NodeID{}
|
||||
// Process
|
||||
|
@ -298,6 +301,8 @@ func (c *Core) Dial(network, address string) (Conn, error) {
|
|||
conn.core.router.doAdmin(func() {
|
||||
conn.startSearch()
|
||||
})
|
||||
conn.sessionMutex.Lock()
|
||||
defer conn.sessionMutex.Unlock()
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue