projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a6619a5
)
* libs/httpd: Memory optimizations part #1
author
Steven Barth
<steven@midlink.org>
Tue, 1 Jul 2008 18:12:34 +0000
(18:12 +0000)
committer
Steven Barth
<steven@midlink.org>
Tue, 1 Jul 2008 18:12:34 +0000
(18:12 +0000)
libs/httpd/luasrc/httpd.lua
patch
|
blob
|
history
diff --git
a/libs/httpd/luasrc/httpd.lua
b/libs/httpd/luasrc/httpd.lua
index
9263dcc
..
ac6e292
100644
(file)
--- a/
libs/httpd/luasrc/httpd.lua
+++ b/
libs/httpd/luasrc/httpd.lua
@@
-30,6
+30,12
@@
local threads = {}
local threadm = {}
local threadi = {}
local threadm = {}
local threadi = {}
+local _meta = {__mode = "k"}
+setmetatable(threads, _meta)
+setmetatable(threadm, _meta)
+setmetatable(threadi, _meta)
+
+
function Socket(ip, port)
local sock, err = socket.bind( ip, port )
function Socket(ip, port)
local sock, err = socket.bind( ip, port )
@@
-86,6
+92,7
@@
function run()
end
function step()
end
function step()
+ print(collectgarbage("count"))
local idle = true
if not THREAD_LIMIT or threadc < THREAD_LIMIT then
local now = os.time()
local idle = true
if not THREAD_LIMIT or threadc < THREAD_LIMIT then
local now = os.time()
@@
-103,10
+110,7
@@
function step()
coroutine.resume(thread, client)
local now = os.time()
if coroutine.status(thread) == "dead" then
coroutine.resume(thread, client)
local now = os.time()
if coroutine.status(thread) == "dead" then
- threads[client] = nil
threadc = threadc - 1
threadc = threadc - 1
- threadm[client] = nil
- threadi[client] = nil
elseif threadm[client] and threadm[client] + THREAD_TIMEOUT < now then
threads[client] = nil
threadc = threadc - 1
elseif threadm[client] and threadm[client] + THREAD_TIMEOUT < now then
threads[client] = nil
threadc = threadc - 1