diff --git a/listener.go b/listener.go index 08896e7..d1a3643 100644 --- a/listener.go +++ b/listener.go @@ -68,9 +68,11 @@ func (sh *SyncHandler) Handle(e Event) { _, ok := sh.chanForSync[device.IfaceName] if ok { close(sh.chanForSync[device.IfaceName]) + delete(sh.chanForSync, device.IfaceName) } chanForSync := make(chan map[string]interface{}) sh.chanForSync[device.IfaceName] = make(chan map[string]interface{}) + for state := range chanForSync { if compareMap(origin, state) { @@ -82,6 +84,7 @@ func (sh *SyncHandler) Handle(e Event) { log.Println("resend: ", origin) err := encoder.Encode(origin) if err != nil { + log.Println("sync routine is died") return } }