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_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
- 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
- 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
- table.insert(self.running, coroutine.running())
-
+
+ self.running[coroutine.running()] = true
+
local r = luci.http.Request(
request.env,
sourcein,
end
--- Test whether the given init script is enabled
--- @return Boolean indicating whether init is enabled
+-- @param name Name of the init script
+-- @return Boolean indicating whether init is enabled
function init.enabled(name)
if luci.fs.access(init.dir..name) then
return ( call(init.dir..name.." enabled") == 0 )
end
--- Get the index of he given init script
--- @return Numeric index value
+-- @param name Name of the init script
+-- @return Numeric index value
function init.index(name)
if luci.fs.access(init.dir..name) then
return call("source "..init.dir..name.."; exit $START")
end
--- Enable the given init script
--- @return Boolean indicating success
+-- @param name Name of the init script
+-- @return Boolean indicating success
function init.enable(name)
if luci.fs.access(init.dir..name) then
return ( call(init.dir..name.." enable") == 1 )
end
--- Disable the given init script
--- @return Boolean indicating success
+-- @param name Name of the init script
+-- @return Boolean indicating success
function init.disable(name)
if luci.fs.access(init.dir..name) then
return ( call(init.dir..name.." disable") == 0 )
$Id$
-%>
-<% include("themes/" .. luci.fs.basename(media) .. "/footer") %>
\ No newline at end of file
+<% include("themes/" .. theme .. "/footer") %>
\ No newline at end of file
function index()
local i18n = luci.i18n.translate
+ local redir = luci.http.formvalue("redir", true) or
+ luci.dispatcher.build_url(unpack(luci.dispatcher.context.request))
entry({"mini", "uci"}, nil, i18n("config"))
- entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30)
- entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20)
- entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10)
+ entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30).query = {redir=redir}
+ entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20).query = {redir=redir}
+ entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10).query = {redir=redir}
end
function convert_changes(changes)
require("luci.config")
m = Map("luci", translate("webui"), translate("a_i_luci1"))
+-- force reload of global luci config namespace to reflect the changes
+function m.commit_handler(self)
+ package.loaded["luci.config"] = nil
+ require("luci.config")
+end
+
+
c = m:section(NamedSection, "main", "core", translate("general"))
l = c:option(ListValue, "lang", translate("language"))
local i18ndir = luci.i18n.i18ndir .. "default."
for k, v in pairs(luci.config.languages) do
- if k:sub(1, 1) ~= "." and luci.fs.isfile(i18ndir .. k .. ".lua") then
+ if k:sub(1, 1) ~= "." and luci.fs.isfile(i18ndir .. k:gsub("_", "-") .. ".lua") then
l:value(k, v)
end
end
end
end
-return m
\ No newline at end of file
+return m
-%>
<%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+<br />
+<br />
+</div>
<h2><a id="content" name="content"><%:config%></a></h2>
<p><%:uci_applied%>:</p>
<code><%=(changes or "-")%>
end
fp:close()
%></code>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+<br />
+<br />
+</div>
<%+footer%>
\ No newline at end of file
-%>
<%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+<br />
+<br />
+</div>
<h2><a id="content" name="content"><%:config%></a></h2>
<h3><%:changes%></h3>
<code><%=changes%></code>
<br /><br />
-<form class="inline" method="get" action="<%=controller%>/mini/uci/apply">
+<form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
<input type="submit" value="<%:apply%>" />
</form>
-<form class="inline" method="get" action="<%=controller%>/mini/uci/revert">
+<form class="inline" method="get" action="<%=controller%>/admin/uci/saveapply">
+ <input type="submit" value="<%:saveapply%>" />
+</form>
+<form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
<input type="submit" value="<%:revert%>" />
</form>
-<%+footer%>
+
+<div>
+<br />
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+</div>
+<%+footer%>
\ No newline at end of file
-%>
<%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+<br />
+<br />
+</div>
<h2><a id="content" name="content"><%:config%></a></h2>
<p><%:uci_reverted%>:</p>
<code><%=(changes or "-")%></code>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
+<br />
+<br />
+</div>
<%+footer%>
\ No newline at end of file
white-space: pre;
}
-div#content ul {
+div#maincontent ul {
margin-left: 2em;
}
float: right;
}
-#content {
+#maincontent {
clear: both;
width: 90%;
margin: 0 auto;
font-size: 80%;
}
-#content h1 {
+#maincontent h2 {
margin: 0.25em 0 0.5em 0;
font-size: 150%;
font-weight: normal;
}
-#content h2 {
+#maincontent h3 {
margin: 0.5em 0;
font-size: 120%;
font-weight: normal;
text-decoration: underline;
}
-#content p {
+#maincontent p {
margin-bottom: 1em;
}
padding-left: 17px;
}
-input.cbi-input-key {
+input.cbi-input-password {
background: url('../resources/cbi/key.gif') no-repeat scroll 1px center;
background-color: inherit;
padding-left: 17px;
div.cbi-section-create {
clear: left;
+ white-space: nowrap;
}
div.cbi-map-descr {
width: 200% !important;
}
-* html div#content {
+* html div#maincontent {
margin-left: -80% !important;
width: 160% !important;
}
<br class="clear" />
</div>
-<div id="content">
+<div id="maincontent">