More resilient broadcast handling (fixes #1907)

My theory is that some error condition on the socket results in it
blocking for writes, which maybe also blocks reads... This separates the
two into separate services with their own socket, with restarts and
retries as appropriates on write timeouts and read/write errors. It
should be more robust, hopefully, but I have a hard time testing the
actual error conditions...
This commit is contained in:
Jakob Borg
2015-06-10 10:07:51 +02:00
parent 885d050e5f
commit 297769ef57
2 changed files with 147 additions and 26 deletions

View File

@@ -86,17 +86,10 @@ func (d *Discoverer) StartLocal(localPort int, localMCAddr string) {
}
func (d *Discoverer) startLocalIPv4Broadcasts(localPort int) {
bb, err := beacon.NewBroadcast(localPort)
if err != nil {
if debug {
l.Debugln("discover: Start local v4:", err)
}
l.Infoln("Local discovery over IPv4 unavailable")
return
}
bb := beacon.NewBroadcast(localPort)
d.beacons = append(d.beacons, bb)
go d.recvAnnouncements(bb)
bb.ServeBackground()
}
func (d *Discoverer) startLocalIPv6Multicasts(localMCAddr string) {