mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 18:41:59 -07:00
Fix announce timers on Solaris (and others, given the right timing) (...)
In the successfull case, we start the timer with NewTimer(0), then do a bunch of stuff during which time it can fire, then reset it with Reset(0). The result is that two timer firings are queued when we enter the select loop, so we do two announcements back to back and fail the tests.
This commit is contained in:
parent
919d005550
commit
2a886576a6
@ -91,16 +91,14 @@ func (d *UDPClient) Start(uri *url.URL, pkt *Announce) error {
|
|||||||
|
|
||||||
func (d *UDPClient) broadcast(pkt []byte) {
|
func (d *UDPClient) broadcast(pkt []byte) {
|
||||||
defer d.wg.Done()
|
defer d.wg.Done()
|
||||||
timer := time.NewTimer(0)
|
|
||||||
|
|
||||||
conn, err := net.ListenUDP(d.url.Scheme, d.listenAddress)
|
conn, err := net.ListenUDP(d.url.Scheme, d.listenAddress)
|
||||||
for err != nil {
|
for err != nil {
|
||||||
timer.Reset(d.errorRetryInterval)
|
|
||||||
l.Warnf("Global UDP discovery (%s): %v; trying again in %v", d.url, err, d.errorRetryInterval)
|
l.Warnf("Global UDP discovery (%s): %v; trying again in %v", d.url, err, d.errorRetryInterval)
|
||||||
select {
|
select {
|
||||||
case <-d.stop:
|
case <-d.stop:
|
||||||
return
|
return
|
||||||
case <-timer.C:
|
case <-time.After(d.errorRetryInterval):
|
||||||
}
|
}
|
||||||
conn, err = net.ListenUDP(d.url.Scheme, d.listenAddress)
|
conn, err = net.ListenUDP(d.url.Scheme, d.listenAddress)
|
||||||
}
|
}
|
||||||
@ -108,18 +106,16 @@ func (d *UDPClient) broadcast(pkt []byte) {
|
|||||||
|
|
||||||
remote, err := net.ResolveUDPAddr(d.url.Scheme, d.url.Host)
|
remote, err := net.ResolveUDPAddr(d.url.Scheme, d.url.Host)
|
||||||
for err != nil {
|
for err != nil {
|
||||||
timer.Reset(d.errorRetryInterval)
|
|
||||||
l.Warnf("Global UDP discovery (%s): %v; trying again in %v", d.url, err, d.errorRetryInterval)
|
l.Warnf("Global UDP discovery (%s): %v; trying again in %v", d.url, err, d.errorRetryInterval)
|
||||||
select {
|
select {
|
||||||
case <-d.stop:
|
case <-d.stop:
|
||||||
return
|
return
|
||||||
case <-timer.C:
|
case <-time.After(d.errorRetryInterval):
|
||||||
}
|
}
|
||||||
remote, err = net.ResolveUDPAddr(d.url.Scheme, d.url.Host)
|
remote, err = net.ResolveUDPAddr(d.url.Scheme, d.url.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.Reset(0)
|
timer := time.NewTimer(0)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-d.stop:
|
case <-d.stop:
|
||||||
|
Loading…
Reference in New Issue
Block a user