--- /dev/null
+--[[
+
+LuCI - Lua Development Framework
+(c) 2009 Steven Barth <steven@midlink.org>
+(c) 2009 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local util = require "luci.util"
+module("luci.store", util.threadlocal)
\ No newline at end of file
-- Scope manipulation routines
--
---- Create a new or get an already existing thread local store associated with
--- the current active coroutine. A thread local store is private a table object
--- whose values can't be accessed from outside of the running coroutine.
--- @return Table value representing the corresponding thread local store
-function threadlocal()
- local tbl = {}
+local tl_meta = {
+ __mode = "k",
- local function get(self, key)
- local t = rawget(self, coxpt[coroutine.running()] or coroutine.running() or 0)
+ __index = function(self, key)
+ local t = rawget(self, coxpt[coroutine.running()]
+ or coroutine.running() or 0)
return t and t[key]
- end
+ end,
- local function set(self, key, value)
+ __newindex = function(self, key, value)
local c = coxpt[coroutine.running()] or coroutine.running() or 0
if not rawget(self, c) then
rawset(self, c, { [key] = value })
rawget(self, c)[key] = value
end
end
+}
- setmetatable(tbl, {__index = get, __newindex = set, __mode = "k"})
-
- return tbl
+--- Create a new or get an already existing thread local store associated with
+-- the current active coroutine. A thread local store is private a table object
+-- whose values can't be accessed from outside of the running coroutine.
+-- @return Table value representing the corresponding thread local store
+function threadlocal(tbl)
+ return setmetatable(tbl or {}, tl_meta)
end
end
end
+ local mypath
if type(config.virtual) == "table" then
for _, v in ipairs(config.virtual) do
+ mypath = mypath or v
vhost:set_handler(v, handler)
end
else
+ mypath = config.virtual
vhost:set_handler(config.virtual, handler)
end
+
+ if config.home then
+ vhost.default = mypath
+ end
end
\ No newline at end of file
-- Call URI part
request.env.PATH_INFO = uri
+ if self.default and uri == "/" then
+ return 302, {Location = self.default}
+ end
+
for k, h in pairs(self.handlers) do
if #k > hlen then
if uri == k or (uri:sub(1, #k) == k and uri:byte(#k+1) == sc) then
set_memory_limit(env.config.memlimit)
end
- client:setsockopt("socket", "rcvtimeo", 5)
- client:setsockopt("socket", "sndtimeo", 5)
+ client:setsockopt("socket", "rcvtimeo", 60)
+ client:setsockopt("socket", "sndtimeo", 60)
repeat
-- parse headers
option physical ''
list virtual /luci
option domain ''
+ option home 1
list exec ':lo'
list exec ':br-lan'
list exec 'root'
option 'virtual' '/'
option 'physical' ':80/luci/splash'
-
\ No newline at end of file
run()
end
+--- Returns the PID of the currently active LuCId process.
+function running()
+ local pid = tonumber(state:get(UCINAME, "main", "pid"))
+ return pid and nixio.kill(pid, 0) and pid
+end
+
--- Stops any running LuCId superprocess.
function stop()
local pid = tonumber(state:get(UCINAME, "main", "pid"))
config LuciWebPublisher luciweb
option name 'LuCI Webapplication'
option physical ''
+ option home 1
list virtual /luci
list virtual /cgi-bin/luci
option domain ''
local table = require "table"
local nixio = require "nixio"
-local getmetatable, assert, pairs, type, tostring =
- getmetatable, assert, pairs, type, tostring
+local getmetatable, assert, pairs, type = getmetatable, assert, pairs, type
+local tostring = tostring
module "nixio.util"
string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
tonumber(memtotal) / 1024,
100 * memcached / memtotal,
- tostring(translate("mem_cached"), "")),
+ tostring(translate("mem_cached", "")),
100 * membuffers / memtotal,
tostring(translate("mem_buffered", "")),
100 * memfree / memtotal,
tostring(translate("mem_free", ""))
+)
f:field(DummyValue, "_systime", translate("m_i_systemtime")).value =
os.date("%c")