projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
59b79c1
)
* luci/libs/httpd: fix spurious Overload errors in luci-httpd
author
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 15 Oct 2008 20:04:46 +0000
(20:04 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 15 Oct 2008 20:04:46 +0000
(20:04 +0000)
libs/httpd/luasrc/httpd/handler/luci.lua
patch
|
blob
|
history
diff --git
a/libs/httpd/luasrc/httpd/handler/luci.lua
b/libs/httpd/luasrc/httpd/handler/luci.lua
index
c3720ff
..
6e9c677
100644
(file)
--- a/
libs/httpd/luasrc/httpd/handler/luci.lua
+++ b/
libs/httpd/luasrc/httpd/handler/luci.lua
@@
-27,7
+27,7
@@
function Luci.__init__(self, limit)
luci.httpd.module.Handler.__init__(self)
self.limit = limit or 5
self.running = {}
luci.httpd.module.Handler.__init__(self)
self.limit = limit or 5
self.running = {}
- setmetatable(self.running, {__mode = "
v
"})
+ setmetatable(self.running, {__mode = "
k
"})
end
function Luci.handle_head(self, ...)
end
function Luci.handle_head(self, ...)
@@
-40,19
+40,31
@@
function Luci.handle_post(self, ...)
end
function Luci.handle_get(self, request, sourcein, sinkerr)
end
function Luci.handle_get(self, request, sourcein, sinkerr)
- if self.limit and #self.running >= self.limit then
+ local reaped = false
+ local running = 0
+
+ for _, v in pairs(self.running) do
+ if v then running = running + 1 end
+ end
+
+ if self.limit and running >= self.limit then
for k, v in ipairs(self.running) do
for k, v in ipairs(self.running) do
- if coroutine.status(v) == "dead" then
- collectgarbage()
- break
+ if coroutine.status(k) == "dead" then
+ self.running[k] = nil
+ running = running - 1
+ reaped = true
end
end
end
end
- if #self.running >= self.limit then
- return self:failure(503, "Overload")
+
+ if reaped then collectgarbage() end
+
+ if running >= self.limit then
+ return self:failure(503, "Overload %i/%i" % { running, self.limit } )
end
end
end
end
- table.insert(self.running, coroutine.running())
-
+
+ self.running[coroutine.running()] = true
+
local r = luci.http.Request(
request.env,
sourcein,
local r = luci.http.Request(
request.env,
sourcein,