mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 03:41:37 +00:00
Multicast actor to prevent races
This commit is contained in:
parent
b959f53fee
commit
2dc136f94a
@ -7,6 +7,7 @@ import (
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/Arceliar/phony"
|
||||
"github.com/gologme/log"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
@ -19,6 +20,7 @@ import (
|
||||
// configured multicast interface, Yggdrasil will attempt to peer with that node
|
||||
// automatically.
|
||||
type Multicast struct {
|
||||
phony.Inbox
|
||||
core *yggdrasil.Core
|
||||
config *config.NodeState
|
||||
log *log.Logger
|
||||
@ -66,8 +68,8 @@ func (m *Multicast) Start() error {
|
||||
|
||||
m.isOpen = true
|
||||
go m.listen()
|
||||
m.multicastStarted()
|
||||
m.announce()
|
||||
m.Act(m, m.multicastStarted)
|
||||
m.Act(m, m.announce)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -243,7 +245,9 @@ func (m *Multicast) announce() {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.announcer = time.AfterFunc(time.Second*15, m.announce)
|
||||
m.announcer = time.AfterFunc(time.Second*15, func() {
|
||||
m.Act(m, m.announce)
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Multicast) listen() {
|
||||
|
@ -39,7 +39,9 @@ func (m *Multicast) multicastStarted() {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.platformhandler = time.AfterFunc(time.Minute, m.multicastStarted)
|
||||
m.platformhandler = time.AfterFunc(time.Minute, func() {
|
||||
m.Act(m, m.multicastStarted)
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
||||
|
Loading…
Reference in New Issue
Block a user