From 1b4b0bba7a380dd07509a0cabea889b4f22a4974 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Tue, 7 May 2024 20:37:13 +0100 Subject: [PATCH] Change handling for ticker stop. --- attribute/monitor.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/attribute/monitor.go b/attribute/monitor.go index db2a362..bc135bc 100644 --- a/attribute/monitor.go +++ b/attribute/monitor.go @@ -222,9 +222,6 @@ func (z *zclMonitor) Detach(ctx context.Context, unconfigure bool) error { if z.ticker != nil { z.pollerStop <- struct{}{} - - z.ticker.Stop() - z.ticker = nil } return nil @@ -233,13 +230,13 @@ func (z *zclMonitor) Detach(ctx context.Context, unconfigure bool) error { func (z *zclMonitor) poller(pctx context.Context) { defer close(z.pollerStop) - tickerCh := z.ticker.C - for { select { case <-z.pollerStop: + z.ticker.Stop() + z.ticker = nil return - case <-tickerCh: + case <-z.ticker.C: _, _, ack, seq := z.transmissionLookup(z.device, zigbee.ProfileHomeAutomation) ctx, done := context.WithTimeout(pctx, time.Duration(5)*time.Second)