mirror of
https://github.com/gSpotx2f/luci-app-internet-detector.git
synced 2025-12-12 22:46:57 +03:00
Running modules with pcall().
This commit is contained in:
@@ -356,7 +356,16 @@ function InternetDetector:mainLoop()
|
||||
_RUNNING = true
|
||||
while _RUNNING do
|
||||
if counter == 0 or counter >= interval then
|
||||
currentStatus = self:checkHosts()
|
||||
if self.debug then
|
||||
currentStatus = self:checkHosts()
|
||||
else
|
||||
local ret, status = pcall(self.checkHosts, self, currentStatus)
|
||||
if ret then
|
||||
currentStatus = status
|
||||
else
|
||||
self:writeLogMessage("err", "Unknown error while checking host!")
|
||||
end
|
||||
end
|
||||
if onStart or not stat.stat(self.statusFile) then
|
||||
self:writeValueToFile(self.statusFile, self:statusJson(
|
||||
currentStatus, self.serviceConfig.instance))
|
||||
@@ -391,7 +400,14 @@ function InternetDetector:mainLoop()
|
||||
mTimeDiff = 1
|
||||
end
|
||||
mLastTime = mTimeNow
|
||||
e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked)
|
||||
if self.debug then
|
||||
e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked)
|
||||
else
|
||||
local ret = pcall(e.run, e, currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked)
|
||||
if not ret then
|
||||
self:writeLogMessage("err", string.format("%s: Unknown error!", e.name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local modStatusChanged = false
|
||||
|
||||
@@ -321,7 +321,7 @@ function Module:requestIP()
|
||||
end
|
||||
|
||||
local retCode, response = self:sendUDPMessage(self._DNSPacket, server, port)
|
||||
if retCode == 0 then
|
||||
if retCode == 0 and response then
|
||||
local retTable = self:decodeMessage(response)
|
||||
if #retTable > 0 then
|
||||
res = table.concat(retTable, ", ")
|
||||
|
||||
Reference in New Issue
Block a user