func (c *ComposedHandler) callRcv(h bh.Handler, msg bh.Msg, ctx bh.RcvContext) ( err error) { defer func() { r := recover() if r == nil { return } if d, ok := r.(time.Duration); ok { ctx.Snooze(d) } err = errors.New(fmt.Sprintf("%v", r)) }() return h.Rcv(msg, ctx) }
func (h *portUpdateHandler) Rcv(msg bh.Msg, ctx bh.RcvContext) error { p := nom.Port(msg.Data().(nom.PortUpdated)) d := ctx.Dict(nodeDict) k := string(p.Node) v, err := d.Get(k) if err != nil { glog.Warningf("%v added before its node", p) ctx.Snooze(1 * time.Second) return nil } np := v.(nodePortsAndLinks) if np.hasPort(p) { glog.Warningf("%v readded") np.removePort(p) } sendLLDPPacket(np.N, p, ctx) np.P = append(np.P, p) return d.Put(k, np) }