mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Wrap the metadata with a mutex to guarantee thread safety across core/router/sessions
This commit is contained in:
parent
97464feba9
commit
042a3400fe
4 changed files with 40 additions and 14 deletions
|
@ -58,7 +58,9 @@ func (r *router) init(core *Core) {
|
|||
r.addr = *address_addrForNodeID(&r.core.dht.nodeID)
|
||||
r.subnet = *address_subnetForNodeID(&r.core.dht.nodeID)
|
||||
in := make(chan []byte, 32) // TODO something better than this...
|
||||
r.core.sessions.myMetadataMutex.RLock()
|
||||
p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub, &boxSharedKey{}, "(self)", r.core.sessions.myMetadata)
|
||||
r.core.sessions.myMetadataMutex.RUnlock()
|
||||
p.out = func(packet []byte) {
|
||||
// This is to make very sure it never blocks
|
||||
select {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue