Преглед изворни кода

Fix luv.run() - call without arguments

luv.run() starts the event loop and takes no callback argument.
Callbacks (timers, fs_events) are registered first, then luv.run() runs them.
Gogs пре 2 месеци
родитељ
комит
0ac8af536d
1 измењених фајлова са 18 додато и 2 уклоњено
  1. 18 2
      usr/sbin/client2server-luv.lua

+ 18 - 2
usr/sbin/client2server-luv.lua

@@ -565,7 +565,9 @@ local function main()
     
     if luv_ok then
         -- Use luv event loop
-        luv.run(function()
+        -- luv.run() starts the event loop. The callbacks we registered
+        -- (timers, fs_events) will run automatically.
+        local function start_monitors()
             -- Start all monitors in parallel
             monitor_wifi_events()
             monitor_dhcp_leases()
@@ -575,8 +577,22 @@ local function main()
             -- Keep the event loop running
             local idle = luv.new_idle()
             luv.idle_start(idle, function()
-                -- Idle work
+                -- Idle work - just keep loop alive
             end)
+        end
+        
+        -- Start monitors first, then run the event loop
+        start_monitors()
+        
+        -- luv.run() - start the event loop (no arguments)
+        local ok, err = pcall(luv.run)
+        if not ok then
+            log("err", "luv.run error: " .. tostring(err))
+            -- Fallback: sequential mode
+            while true do
+                os.execute("sleep 60")
+            end
+        end
             
             -- WebSocket connection and keepalive
             while true do