119 _realG_mt.__newindex = old_newindex; |
119 _realG_mt.__newindex = old_newindex; |
120 return ret; |
120 return ret; |
121 end |
121 end |
122 return _real_require(...); |
122 return _real_require(...); |
123 end |
123 end |
|
124 end |
|
125 |
|
126 function set_function_metatable() |
|
127 local mt = {}; |
|
128 function mt.__index(f, upvalue) |
|
129 local i, name, value = 0; |
|
130 repeat |
|
131 i = i + 1; |
|
132 name, value = debug.getupvalue(f, i); |
|
133 until name == upvalue or name == nil; |
|
134 return value; |
|
135 end |
|
136 function mt.__newindex(f, upvalue, value) |
|
137 local i, name = 0; |
|
138 repeat |
|
139 i = i + 1; |
|
140 name = debug.getupvalue(f, i); |
|
141 until name == upvalue or name == nil; |
|
142 if name then |
|
143 debug.setupvalue(f, i, value); |
|
144 end |
|
145 end |
|
146 debug.setmetatable(function() end, mt); |
124 end |
147 end |
125 |
148 |
126 function init_global_state() |
149 function init_global_state() |
127 bare_sessions = {}; |
150 bare_sessions = {}; |
128 full_sessions = {}; |
151 full_sessions = {}; |
416 -- previous steps to have already been performed |
439 -- previous steps to have already been performed |
417 read_config(); |
440 read_config(); |
418 init_logging(); |
441 init_logging(); |
419 check_dependencies(); |
442 check_dependencies(); |
420 sandbox_require(); |
443 sandbox_require(); |
|
444 set_function_metatable(); |
421 load_libraries(); |
445 load_libraries(); |
422 init_global_state(); |
446 init_global_state(); |
423 read_version(); |
447 read_version(); |
424 log("info", "Hello and welcome to Prosody version %s", prosody.version); |
448 log("info", "Hello and welcome to Prosody version %s", prosody.version); |
425 load_secondary_libraries(); |
449 load_secondary_libraries(); |