diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-21 22:52:15 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-21 22:52:15 +0100 |
commit | e0a85aed90d0d4a5a6bcf8220cef38f15ec3844b (patch) | |
tree | 6ba783acd4607605ad3abb1c9d2af05ea099bf13 /core/moduleapi.lua | |
parent | 4ff0a4613db3b11d7a9dd4c89c020cec3e89bad4 (diff) | |
download | prosody-e0a85aed90d0d4a5a6bcf8220cef38f15ec3844b.tar.gz prosody-e0a85aed90d0d4a5a6bcf8220cef38f15ec3844b.zip |
moduleapi: Have modules internally store a reference to shared tables they use, to ensure they don't get collected while any module that had access to that table is still loaded (thanks Zash)
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r-- | core/moduleapi.lua | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index a577c07a..7a3bd1c8 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -135,6 +135,7 @@ end -- Intentionally does not allow the table at a path to be _set_, it -- is auto-created if it does not exist. function api:shared(...) + if not self.shared_data then self.shared_data = {}; end local paths = { n = select("#", ...), ... }; local data_array = {}; local default_path_components = { self.host, self.name }; @@ -150,6 +151,7 @@ function api:shared(...) shared_data[path] = shared; end t_insert(data_array, shared); + self.shared_data[path] = shared; end return unpack(data_array); end |