diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-06 22:26:46 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-06 22:26:46 +0000 |
commit | 238404ee8354330822f820d74b33d8314be69a45 (patch) | |
tree | dfee37e1745054a2b0b92ea7e141c61a99b655da /libs/lucid | |
parent | 644bc4ac3a727b23a849d61b5f26b5b79b25f8f4 (diff) |
libs/lucid: only execute handlers if daemon is below the thread limit, this allows to hold connections without having to fork immediately
Diffstat (limited to 'libs/lucid')
-rw-r--r-- | libs/lucid/luasrc/lucid.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libs/lucid/luasrc/lucid.lua b/libs/lucid/luasrc/lucid.lua index b10365579..4963ccc30 100644 --- a/libs/lucid/luasrc/lucid.lua +++ b/libs/lucid/luasrc/lucid.lua @@ -110,19 +110,22 @@ end -- This main function of LuCId will wait for events on given file descriptors. function run() local pollint = tonumber((cursor:get(UCINAME, "main", "pollinterval"))) + local threadlimit = tonumber(cursor:get(UCINAME, "main", "threadlimit")) 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 - for _, polle in ipairs(pollt) do - if polle.revents ~= 0 and polle.handler then - polle.handler(polle) + if stat and stat > 0 then + for _, polle in ipairs(pollt) do + if polle.revents ~= 0 and polle.handler then + polle.handler(polle) + end end + elseif stat == 0 then + ifaddrs = nixio.getifaddrs() + collectgarbage("collect") end - elseif stat == 0 then - ifaddrs = nixio.getifaddrs() - collectgarbage("collect") end for _, cb in ipairs(tickt) do @@ -317,4 +320,4 @@ function daemonize() nixio.dup(devnull, nixio.stderr) return true -end
\ No newline at end of file +end |