Skip to content

Commit

Permalink
Change handling for ticker stop.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed May 7, 2024
1 parent 90338f7 commit 1b4b0bb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions attribute/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1b4b0bb

Please sign in to comment.