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:
02cce96
)
* libs/util: Fixed memory leaks in threadlocal implementations
author
Steven Barth
<steven@midlink.org>
Mon, 23 Jun 2008 20:01:34 +0000
(20:01 +0000)
committer
Steven Barth
<steven@midlink.org>
Mon, 23 Jun 2008 20:01:34 +0000
(20:01 +0000)
libs/core/luasrc/util.lua
patch
|
blob
|
history
diff --git
a/libs/core/luasrc/util.lua
b/libs/core/luasrc/util.lua
index
5168560
..
e227fc7
100644
(file)
--- a/
libs/core/luasrc/util.lua
+++ b/
libs/core/luasrc/util.lua
@@
-281,16
+281,9
@@
function threadlocal()
rawset(self, thread, {})
end
rawget(self, thread)[key] = value
rawset(self, thread, {})
end
rawget(self, thread)[key] = value
-
- -- Avoid memory leaks by removing abandoned stores
- for k, v in pairs(self) do
- if type(k) == "thread" and coroutine.status(k) == "dead" then
- rawset(self, k, nil)
- end
- end
end
end
- setmetatable(tbl, {__index = get, __newindex = set})
+ setmetatable(tbl, {__index = get, __newindex = set
, __mode = "k"
})
return tbl
end
return tbl
end
@@
-404,6
+397,7
@@
end
local performResume, handleReturnValue
local oldpcall, oldxpcall = pcall, xpcall
coxpt = {}
local performResume, handleReturnValue
local oldpcall, oldxpcall = pcall, xpcall
coxpt = {}
+setmetatable(coxpt, {__mode = "kv"})
function handleReturnValue(err, co, status, ...)
if not status then
function handleReturnValue(err, co, status, ...)
if not status then
@@
-429,6
+423,7
@@
function coxpcall(f, err, ...)
end
local c = coroutine.running()
coxpt[co] = coxpt[c] or c or 0
end
local c = coroutine.running()
coxpt[co] = coxpt[c] or c or 0
+
return performResume(err, co, ...)
end
return performResume(err, co, ...)
end