Switch back to using an actor to manage link state, and slighty randomize the delay between multicast announcements. This seems to fix the issue with duplicate connections (and breaks a livelock in the multicast code where both nodes keep closing the listen side of their connection, but that's kind of a hack, we need a better solution)

This commit is contained in:
Arceliar 2023-06-18 03:40:40 -05:00
parent 2eda59d9e4
commit c1ae9ea0d4
3 changed files with 257 additions and 241 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"fmt"
"math/rand"
"net"
"net/url"
"time"
@ -337,7 +338,8 @@ func (m *Multicast) _announce() {
break
}
}
m._timer = time.AfterFunc(time.Second, func() {
annInterval := time.Second + time.Microsecond*(time.Duration(rand.Intn(1048576))) // Randomize delay
m._timer = time.AfterFunc(annInterval, func() {
m.Act(nil, m._announce)
})
}