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