libs/lucid: only execute handlers if daemon is below the thread limit, this allows to hold connections without having to fork immediately
This commit is contained in:
parent
644bc4ac3a
commit
238404ee83
1 changed files with 12 additions and 9 deletions
|
@ -110,19 +110,22 @@ end
|
||||||
-- This main function of LuCId will wait for events on given file descriptors.
|
-- This main function of LuCId will wait for events on given file descriptors.
|
||||||
function run()
|
function run()
|
||||||
local pollint = tonumber((cursor:get(UCINAME, "main", "pollinterval")))
|
local pollint = tonumber((cursor:get(UCINAME, "main", "pollinterval")))
|
||||||
|
local threadlimit = tonumber(cursor:get(UCINAME, "main", "threadlimit"))
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local stat, code = nixio.poll(pollt, pollint)
|
if not threadlimit or tcount < threadlimit then
|
||||||
|
local stat, code = nixio.poll(pollt, pollint)
|
||||||
|
|
||||||
if stat and stat > 0 then
|
if stat and stat > 0 then
|
||||||
for _, polle in ipairs(pollt) do
|
for _, polle in ipairs(pollt) do
|
||||||
if polle.revents ~= 0 and polle.handler then
|
if polle.revents ~= 0 and polle.handler then
|
||||||
polle.handler(polle)
|
polle.handler(polle)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
elseif stat == 0 then
|
||||||
|
ifaddrs = nixio.getifaddrs()
|
||||||
|
collectgarbage("collect")
|
||||||
end
|
end
|
||||||
elseif stat == 0 then
|
|
||||||
ifaddrs = nixio.getifaddrs()
|
|
||||||
collectgarbage("collect")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, cb in ipairs(tickt) do
|
for _, cb in ipairs(tickt) do
|
||||||
|
@ -317,4 +320,4 @@ function daemonize()
|
||||||
nixio.dup(devnull, nixio.stderr)
|
nixio.dup(devnull, nixio.stderr)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue