Skip to content

Commit

Permalink
Fix: handle reload failures a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
betamos committed Aug 25, 2023
1 parent 34ef271 commit 782f54a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,21 @@ loop:
if !timer.Stop() {
<-timer.C
}
bo.reset()
c.conn.loadIfaces()
now = time.Now()
bo.reset()
_, err := c.conn.loadIfaces()
if err != nil {
c.opts.logger.Warn("reload failed (ifaces unchanged)", "err", err)
}
c.opts.logger.Debug("reload", "ifaces", c.conn.ifaces)
case m, ok := <-msgCh:
if !timer.Stop() {
<-timer.C
}
now = time.Now()
if !ok {
break loop
}
now = time.Now()
msg = &m
case now = <-timer.C:
}
Expand Down
5 changes: 4 additions & 1 deletion dual_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ func newDualConn(ifacesFn func() ([]net.Interface, error), network string) (*dua
func (c *dualConn) loadIfaces() (changed bool, err error) {
ifaces := make(map[int]*Interface) // new ifaces
netIfaces, err := c.ifacesFn()
if err != nil {
return false, err
}
for _, netIface := range netIfaces {
if !isMulticastInterface(netIface) {
continue
}
v4, v6, err := netIfaceAddrs(netIface)
if err != nil {
continue
return false, err
}
iface := &Interface{Interface: netIface}
// Join will fail if called multiple times, just attempt for now
Expand Down

0 comments on commit 782f54a

Please sign in to comment.