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
|
||||
--
|
||||
|
||||
--- 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 })
|
||||
|
@ -134,10 +131,14 @@ function threadlocal()
|
|||
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
|
||||
|
||||
|
||||
|
|
|
@ -52,11 +52,18 @@ function factory(server, config)
|
|||
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
|
|
@ -173,6 +173,10 @@ function VHost.process(self, request, ...)
|
|||
-- 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
|
||||
|
@ -365,8 +369,8 @@ function Server.process(self, client, env)
|
|||
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
|
||||
|
|
|
@ -19,6 +19,7 @@ config LuciWebPublisher luciweb
|
|||
option physical ''
|
||||
list virtual /luci
|
||||
option domain ''
|
||||
option home 1
|
||||
list exec ':lo'
|
||||
list exec ':br-lan'
|
||||
list exec 'root'
|
||||
|
@ -71,4 +72,3 @@ config 'Redirector' 'splashredir'
|
|||
option 'virtual' '/'
|
||||
option 'physical' ':80/luci/splash'
|
||||
|
||||
|
|
@ -60,6 +60,12 @@ function start()
|
|||
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"))
|
||||
|
|
|
@ -15,6 +15,7 @@ config DirectoryPublisher webroot
|
|||
config LuciWebPublisher luciweb
|
||||
option name 'LuCI Webapplication'
|
||||
option physical ''
|
||||
option home 1
|
||||
list virtual /luci
|
||||
list virtual /cgi-bin/luci
|
||||
option domain ''
|
||||
|
|
|
@ -14,8 +14,8 @@ $Id$
|
|||
|
||||
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"
|
||||
|
||||
|
|
|
@ -27,11 +27,12 @@ f:field(DummyValue, "_memtotal", translate("m_i_memory")).value =
|
|||
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")
|
||||
|
|
Loading…
Reference in a new issue