Redial failed connections if possible (#983)

This commit is contained in:
Neil Alexander 2022-11-12 11:30:03 +00:00 committed by GitHub
parent 0da871f528
commit 7efd66932f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 124 additions and 28 deletions

View file

@ -30,6 +30,7 @@ type Multicast struct {
_isOpen bool
_listeners map[string]*listenerInfo
_interfaces map[string]*interfaceInfo
_timer *time.Timer
config struct {
_groupAddr GroupAddress
_interfaces map[MulticastInterface]struct{}
@ -207,6 +208,15 @@ func (m *Multicast) _getAllowedInterfaces() map[string]*interfaceInfo {
return interfaces
}
func (m *Multicast) AnnounceNow() {
phony.Block(m, func() {
if m._timer != nil && !m._timer.Stop() {
<-m._timer.C
}
m.Act(nil, m._announce)
})
}
func (m *Multicast) _announce() {
if !m._isOpen {
return
@ -329,7 +339,7 @@ func (m *Multicast) _announce() {
break
}
}
time.AfterFunc(time.Second, func() {
m._timer = time.AfterFunc(time.Second, func() {
m.Act(nil, m._announce)
})
}