summaryrefslogtreecommitdiffhomepage
path: root/libs/httpd/luasrc/httpd.lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-01 18:12:34 +0000
committerSteven Barth <steven@midlink.org>2008-07-01 18:12:34 +0000
commit77c7cc65965203e0c2c87bfc37c250e9872872fa (patch)
tree4b509e267e7005d207b44df2691788bf5957d63b /libs/httpd/luasrc/httpd.lua
parenta6619a5cb7a05e1e8c761b27f28ec2c5e791020a (diff)
* libs/httpd: Memory optimizations part #1
Diffstat (limited to 'libs/httpd/luasrc/httpd.lua')
-rw-r--r--libs/httpd/luasrc/httpd.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/libs/httpd/luasrc/httpd.lua b/libs/httpd/luasrc/httpd.lua
index 9263dcc6d8..ac6e29216b 100644
--- a/libs/httpd/luasrc/httpd.lua
+++ b/libs/httpd/luasrc/httpd.lua
@@ -30,6 +30,12 @@ local threads = {}
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 )
@@ -86,6 +92,7 @@ function run()
end
function step()
+ print(collectgarbage("count"))
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
- threads[client] = nil
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