Remove overload protection from SDK httpd
[project/luci.git] / libs / httpd / luasrc / httpd / handler / luci.lua
index 2328832..8ccf7c8 100644 (file)
@@ -27,12 +27,11 @@ function Luci.__init__(self, limit)
        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, ...)
        local response, sourceout = self:handle_get(...)
-       self.running = self.running - 1
        return response
 end
 
@@ -41,11 +40,6 @@ function Luci.handle_post(self, ...)
 end
 
 function Luci.handle_get(self, request, sourcein, sinkerr)
-       if self.limit and #self.running >= self.limit then
-               return self:failure(503, "Overload")
-       end
-       table.insert(self.running, coroutine.running())
-       
        local r = luci.http.Request(
                request.env,
                sourcein,
@@ -67,7 +61,6 @@ function Luci.handle_get(self, request, sourcein, sinkerr)
                        status = 500
                        headers["Content-Type"] = "text/plain"
                        local err = {id}
-                       self.running = self.running - 1
                        return Response( status, headers ), function() return table.remove(err) end
                end
 
@@ -86,7 +79,11 @@ function Luci.handle_get(self, request, sourcein, sinkerr)
                        return true
                elseif id == 5 then
                        active = false
-                       return true
+
+                       while (coroutine.resume(x)) do
+                       end
+
+                       return nil
                elseif id == 4 then
                        return data
                end
@@ -95,9 +92,5 @@ function Luci.handle_get(self, request, sourcein, sinkerr)
                end
        end
 
-       headers["Expires"] = luci.http.protocol.date.to_http( os.time() )
-       headers["Date"]    = headers["Expires"]
-       headers["Cache-Control"] = "no-cache"
-
        return Response(status, headers), iter
 end