diff options
author | Steven Barth <steven@midlink.org> | 2008-06-23 20:01:34 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-23 20:01:34 +0000 |
commit | 1e413b92510f6da7f97e2cb1bc7a1cc45ca93bda (patch) | |
tree | 0ee6c156d7e9f152a8477130d54d54440d8b1297 | |
parent | 02cce96c83dfa42de026894d9447ce75f731510a (diff) |
* libs/util: Fixed memory leaks in threadlocal implementations
-rw-r--r-- | libs/core/luasrc/util.lua | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 516856057..e227fc730 100644 --- 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 - - -- 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 - setmetatable(tbl, {__index = get, __newindex = set}) + setmetatable(tbl, {__index = get, __newindex = set, __mode = "k"}) return tbl end @@ -404,6 +397,7 @@ end local performResume, handleReturnValue local oldpcall, oldxpcall = pcall, xpcall coxpt = {} +setmetatable(coxpt, {__mode = "kv"}) 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 + return performResume(err, co, ...) end |