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