mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 19:39:05 +00:00
Continue discovery on connect errors (fixes #324)
Continues trying to connect to the discovery server at regular intervals despite failure. Whether or not to retry and retry interval should be specified in configuration (not currently in this fix).
This commit is contained in:
parent
a720f90a70
commit
37d83a4e2e
@ -168,16 +168,21 @@ func (d *Discoverer) sendLocalAnnouncements() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Discoverer) sendExternalAnnouncements() {
|
func (d *Discoverer) sendExternalAnnouncements() {
|
||||||
|
// this should go in the Discoverer struct
|
||||||
|
errorRetryIntv := 60 * time.Second
|
||||||
|
|
||||||
remote, err := net.ResolveUDPAddr("udp", d.extServer)
|
remote, err := net.ResolveUDPAddr("udp", d.extServer)
|
||||||
if err != nil {
|
for err != nil {
|
||||||
l.Warnf("Global discovery: %v; no external announcements", err)
|
l.Warnf("Global discovery: %v; trying again in %v", err, errorRetryIntv)
|
||||||
return
|
time.Sleep(errorRetryIntv)
|
||||||
|
remote, err = net.ResolveUDPAddr("udp", d.extServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := net.ListenUDP("udp", nil)
|
conn, err := net.ListenUDP("udp", nil)
|
||||||
if err != nil {
|
for err != nil {
|
||||||
l.Warnf("Global discovery: %v; no external announcements", err)
|
l.Warnf("Global discovery: %v; trying again in %v", err, errorRetryIntv)
|
||||||
return
|
time.Sleep(errorRetryIntv)
|
||||||
|
conn, err = net.ListenUDP("udp", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf []byte
|
var buf []byte
|
||||||
@ -198,7 +203,7 @@ func (d *Discoverer) sendExternalAnnouncements() {
|
|||||||
l.Debugf("discover: send announcement -> %v\n%s", remote, hex.Dump(buf))
|
l.Debugf("discover: send announcement -> %v\n%s", remote, hex.Dump(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.WriteTo(buf, remote)
|
_, err := conn.WriteTo(buf, remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugln("discover: warning:", err)
|
l.Debugln("discover: warning:", err)
|
||||||
@ -222,7 +227,7 @@ func (d *Discoverer) sendExternalAnnouncements() {
|
|||||||
if ok {
|
if ok {
|
||||||
time.Sleep(d.globalBcastIntv)
|
time.Sleep(d.globalBcastIntv)
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(60 * time.Second)
|
time.Sleep(errorRetryIntv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user