File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -339,10 +339,18 @@ func startBacklightTickers() {
339
339
return
340
340
}
341
341
342
- if dimTicker == nil && config .DisplayDimAfterSec != 0 {
342
+ // Stop existing tickers to prevent multiple active instances on repeated calls
343
+ if dimTicker != nil {
344
+ dimTicker .Stop ()
345
+ }
346
+
347
+ if offTicker != nil {
348
+ offTicker .Stop ()
349
+ }
350
+
351
+ if config .DisplayDimAfterSec != 0 {
343
352
displayLogger .Info ().Msg ("dim_ticker has started" )
344
353
dimTicker = time .NewTicker (time .Duration (config .DisplayDimAfterSec ) * time .Second )
345
- defer dimTicker .Stop ()
346
354
347
355
go func () {
348
356
for { //nolint:staticcheck
@@ -354,10 +362,9 @@ func startBacklightTickers() {
354
362
}()
355
363
}
356
364
357
- if offTicker == nil && config .DisplayOffAfterSec != 0 {
365
+ if config .DisplayOffAfterSec != 0 {
358
366
displayLogger .Info ().Msg ("off_ticker has started" )
359
367
offTicker = time .NewTicker (time .Duration (config .DisplayOffAfterSec ) * time .Second )
360
- defer offTicker .Stop ()
361
368
362
369
go func () {
363
370
for { //nolint:staticcheck
Original file line number Diff line number Diff line change 5
5
"fmt"
6
6
"os"
7
7
"path/filepath"
8
+ "reflect"
8
9
"time"
9
10
10
11
"github.com/fsnotify/fsnotify"
@@ -149,6 +150,12 @@ func (c *DHCPClient) loadLeaseFile() error {
149
150
}
150
151
151
152
isFirstLoad := c .lease == nil
153
+
154
+ // Skip processing if lease hasn't changed to avoid unnecessary wake-ups.
155
+ if reflect .DeepEqual (c .lease , lease ) {
156
+ return nil
157
+ }
158
+
152
159
c .lease = lease
153
160
154
161
if lease .IPAddress == nil {
You can’t perform that action at this time.
0 commit comments