webmcp

changeset 286:fc2aba7d5db9

Code cleanup regarding loading of "multirand" library
author jbe
date Sun Mar 22 02:10:57 2015 +0100 (2015-03-22)
parents aacddd07e471
children a9ad9186a922
files framework/bin/mcp.lua framework/env/__init.lua
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
     2.1 --- a/framework/env/__init.lua	Sun Mar 22 02:09:49 2015 +0100
     2.2 +++ b/framework/env/__init.lua	Sun Mar 22 02:10:57 2015 +0100
     2.3 @@ -37,15 +37,15 @@
     2.4  end
     2.5  --//--
     2.6  
     2.7 --- load libraries
     2.8 +-- load libraries (except "multirand", which must be loaded after forking)
     2.9  extos       = require 'extos'
    2.10  nihil       = require 'nihil'
    2.11 ---multirand   = require 'multirand'  -- TODO: load after forking
    2.12  mondelefant = require 'mondelefant'
    2.13  mondelefant.connection_prototype.error_objects = true
    2.14  atom        = require 'atom'
    2.15  json        = require 'json'
    2.16  require 'mondelefant_atom_connector'
    2.17 +-- NOTE: "multirand" library is loaded in mcp.lua after forking
    2.18  
    2.19  --[[--
    2.20  config  -- table to store application configuration

Impressum / About Us