Selaa lähdekoodia

Fix DHCP monitor: use timer instead of fs_event (more compatible)

Gogs 2 kuukautta sitten
vanhempi
sitoutus
aeca0f4162
1 muutettua tiedostoa jossa 8 lisäystä ja 16 poistoa
  1. 8 16
      usr/sbin/client2server-luv.lua

+ 8 - 16
usr/sbin/client2server-luv.lua

@@ -351,20 +351,12 @@ local function monitor_dhcp_leases()
         monitor_dhcp_sequential()
         return
     end
-
-    local lease_file = "/var/lib/dnsmasq/dnsmasq.leases"
+    
+    -- Use timer-based polling instead of fs_event (more compatible)
+    local timer = luv.new_timer()
     local old_leases = {}
-    local last_mtime = 0
-
-    -- Use luv fs_event to watch file changes
-    local fs_event = luv.new_fs_event()
-
-    luv.fs_event_start(fs_event, lease_file, function(err)
-        if err then
-            log("err", "DHCP fs_event error: " .. err)
-            return
-        end
-
+    
+    luv.timer_start(timer, cfg.dhcp_poll_interval * 1000, cfg.dhcp_poll_interval * 1000, function()
         -- File changed, process leases
         process_leases(old_leases, function(mac, ip, hostname, action)
             local ev = build_event("dhcp_lease", {
@@ -376,10 +368,10 @@ local function monitor_dhcp_leases()
             log("info", "DHCP: " .. action .. " - " .. mac .. " -> " .. ip)
             buffer.add(ev)
         end)
-
+        
         old_leases = read_leases()
     end)
-
+    
     log("info", "DHCP lease monitor started")
 end
 
@@ -589,7 +581,7 @@ local function main()
         if not ok then
             log("err", "luv.run error: " .. tostring(err))
         end
-        
+
         -- WebSocket connection and keepalive
         while true do
             log("info", "Connecting to server...")