Skip processing if lease hasn't changed to avoid unnecessary wake-ups

This commit is contained in:
Alex Ballas 2025-05-29 15:25:51 +03:00
parent 3cd75c8de7
commit 41f9d6102f
1 changed files with 7 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"time" "time"
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"
@ -149,6 +150,12 @@ func (c *DHCPClient) loadLeaseFile() error {
} }
isFirstLoad := c.lease == nil isFirstLoad := c.lease == nil
// Skip processing if lease hasn't changed to avoid unnecessary wake-ups.
if reflect.DeepEqual(c.lease, lease) {
return nil
}
c.lease = lease c.lease = lease
if lease.IPAddress == nil { if lease.IPAddress == nil {