webmcp
diff framework/bin/mcp.lua @ 286:fc2aba7d5db9
Code cleanup regarding loading of "multirand" library
author | jbe |
---|---|
date | Sun Mar 22 02:10:57 2015 +0100 (2015-03-22) |
parents | b5d0c0ab3ce2 |
children | c51f283dfb0d |
line diff
1.1 --- a/framework/bin/mcp.lua Sun Mar 22 02:09:49 2015 +0100 1.2 +++ b/framework/bin/mcp.lua Sun Mar 22 02:10:57 2015 +0100 1.3 @@ -202,10 +202,15 @@ 1.4 end 1.5 execute.prefork_initializers() 1.6 1.7 +-- define post-fork initialization function (including loading of "multirand" library) 1.8 +local function postfork_init() 1.9 + _G.multirand = require "multirand" 1.10 + execute.postfork_initializers() 1.11 +end 1.12 + 1.13 -- interactive console mode 1.14 if WEBMCP_MODE == "interactive" then 1.15 - _G.multirand = require "multirand" -- TODO: cleaner solution 1.16 - execute.postfork_initializers() 1.17 + postfork_init() 1.18 trace.disable() -- avoids memory leakage (TODO: needs general solution for moonbridge?) 1.19 end 1.20 1.21 @@ -223,10 +228,7 @@ 1.22 end 1.23 local outer_handler = http.generate_handler(inner_handler, http_options) 1.24 --listener.prepare = execute.postfork_initializers 1.25 - listener.prepare = function() 1.26 - _G.multirand = require "multirand" 1.27 - execute.postfork_initializers() 1.28 - end 1.29 + listener.prepare = postfork_init 1.30 listener.connect = function(socket) 1.31 outer_handler(socket) 1.32 return request_count < min_requests_per_connect