luci-0.9: merge r5154-r5161
This commit is contained in:
parent
ad8c39598e
commit
32577be4b9
9 changed files with 55 additions and 19 deletions
16
libs/core/luasrc/store.lua
Normal file
16
libs/core/luasrc/store.lua
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--[[
|
||||||
|
|
||||||
|
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)
|
|
@ -114,19 +114,16 @@ end
|
||||||
-- Scope manipulation routines
|
-- Scope manipulation routines
|
||||||
--
|
--
|
||||||
|
|
||||||
--- Create a new or get an already existing thread local store associated with
|
local tl_meta = {
|
||||||
-- the current active coroutine. A thread local store is private a table object
|
__mode = "k",
|
||||||
-- 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 function get(self, key)
|
__index = function(self, key)
|
||||||
local t = rawget(self, coxpt[coroutine.running()] or coroutine.running() or 0)
|
local t = rawget(self, coxpt[coroutine.running()]
|
||||||
|
or coroutine.running() or 0)
|
||||||
return t and t[key]
|
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
|
local c = coxpt[coroutine.running()] or coroutine.running() or 0
|
||||||
if not rawget(self, c) then
|
if not rawget(self, c) then
|
||||||
rawset(self, c, { [key] = value })
|
rawset(self, c, { [key] = value })
|
||||||
|
@ -134,10 +131,14 @@ function threadlocal()
|
||||||
rawget(self, c)[key] = value
|
rawget(self, c)[key] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
}
|
||||||
|
|
||||||
setmetatable(tbl, {__index = get, __newindex = set, __mode = "k"})
|
--- 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
|
||||||
return tbl
|
-- 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,18 @@ function factory(server, config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local mypath
|
||||||
if type(config.virtual) == "table" then
|
if type(config.virtual) == "table" then
|
||||||
for _, v in ipairs(config.virtual) do
|
for _, v in ipairs(config.virtual) do
|
||||||
|
mypath = mypath or v
|
||||||
vhost:set_handler(v, handler)
|
vhost:set_handler(v, handler)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
mypath = config.virtual
|
||||||
vhost:set_handler(config.virtual, handler)
|
vhost:set_handler(config.virtual, handler)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if config.home then
|
||||||
|
vhost.default = mypath
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -173,6 +173,10 @@ function VHost.process(self, request, ...)
|
||||||
-- Call URI part
|
-- Call URI part
|
||||||
request.env.PATH_INFO = uri
|
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
|
for k, h in pairs(self.handlers) do
|
||||||
if #k > hlen then
|
if #k > hlen then
|
||||||
if uri == k or (uri:sub(1, #k) == k and uri:byte(#k+1) == sc) then
|
if uri == k or (uri:sub(1, #k) == k and uri:byte(#k+1) == sc) then
|
||||||
|
@ -365,8 +369,8 @@ function Server.process(self, client, env)
|
||||||
set_memory_limit(env.config.memlimit)
|
set_memory_limit(env.config.memlimit)
|
||||||
end
|
end
|
||||||
|
|
||||||
client:setsockopt("socket", "rcvtimeo", 5)
|
client:setsockopt("socket", "rcvtimeo", 60)
|
||||||
client:setsockopt("socket", "sndtimeo", 5)
|
client:setsockopt("socket", "sndtimeo", 60)
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
-- parse headers
|
-- parse headers
|
||||||
|
|
|
@ -19,6 +19,7 @@ config LuciWebPublisher luciweb
|
||||||
option physical ''
|
option physical ''
|
||||||
list virtual /luci
|
list virtual /luci
|
||||||
option domain ''
|
option domain ''
|
||||||
|
option home 1
|
||||||
list exec ':lo'
|
list exec ':lo'
|
||||||
list exec ':br-lan'
|
list exec ':br-lan'
|
||||||
list exec 'root'
|
list exec 'root'
|
||||||
|
@ -71,4 +72,3 @@ config 'Redirector' 'splashredir'
|
||||||
option 'virtual' '/'
|
option 'virtual' '/'
|
||||||
option 'physical' ':80/luci/splash'
|
option 'physical' ':80/luci/splash'
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,12 @@ function start()
|
||||||
run()
|
run()
|
||||||
end
|
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.
|
--- Stops any running LuCId superprocess.
|
||||||
function stop()
|
function stop()
|
||||||
local pid = tonumber(state:get(UCINAME, "main", "pid"))
|
local pid = tonumber(state:get(UCINAME, "main", "pid"))
|
||||||
|
|
|
@ -15,6 +15,7 @@ config DirectoryPublisher webroot
|
||||||
config LuciWebPublisher luciweb
|
config LuciWebPublisher luciweb
|
||||||
option name 'LuCI Webapplication'
|
option name 'LuCI Webapplication'
|
||||||
option physical ''
|
option physical ''
|
||||||
|
option home 1
|
||||||
list virtual /luci
|
list virtual /luci
|
||||||
list virtual /cgi-bin/luci
|
list virtual /cgi-bin/luci
|
||||||
option domain ''
|
option domain ''
|
||||||
|
|
|
@ -14,8 +14,8 @@ $Id$
|
||||||
|
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local nixio = require "nixio"
|
local nixio = require "nixio"
|
||||||
local getmetatable, assert, pairs, type, tostring =
|
local getmetatable, assert, pairs, type = getmetatable, assert, pairs, type
|
||||||
getmetatable, assert, pairs, type, tostring
|
local tostring = tostring
|
||||||
|
|
||||||
module "nixio.util"
|
module "nixio.util"
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,12 @@ f:field(DummyValue, "_memtotal", translate("m_i_memory")).value =
|
||||||
string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
||||||
tonumber(memtotal) / 1024,
|
tonumber(memtotal) / 1024,
|
||||||
100 * memcached / memtotal,
|
100 * memcached / memtotal,
|
||||||
tostring(translate("mem_cached"), "")),
|
tostring(translate("mem_cached", "")),
|
||||||
100 * membuffers / memtotal,
|
100 * membuffers / memtotal,
|
||||||
tostring(translate("mem_buffered", "")),
|
tostring(translate("mem_buffered", "")),
|
||||||
100 * memfree / memtotal,
|
100 * memfree / memtotal,
|
||||||
tostring(translate("mem_free", ""))
|
tostring(translate("mem_free", ""))
|
||||||
|
)
|
||||||
|
|
||||||
f:field(DummyValue, "_systime", translate("m_i_systemtime")).value =
|
f:field(DummyValue, "_systime", translate("m_i_systemtime")).value =
|
||||||
os.date("%c")
|
os.date("%c")
|
||||||
|
|
Loading…
Reference in a new issue