webmcp

changeset 483:5b0066fd326e

Removed termination handling from WebMCP (to be done by moonbridge_io if needed)
author jbe
date Sun Jun 11 01:32:25 2017 +0200 (12 months ago)
parents 87c87be92154
children 66086fa01d6e
files framework/bin/mcp.lua
line diff
     1.1 --- a/framework/bin/mcp.lua	Fri Jun 09 18:19:15 2017 +0200
     1.2 +++ b/framework/bin/mcp.lua	Sun Jun 11 01:32:25 2017 +0200
     1.3 @@ -286,7 +286,6 @@
     1.4  
     1.5  -- define post-fork initialization function (including loading of "multirand" library)
     1.6  local function postfork_init()
     1.7 -  sigterm_socket = moonbridge_io.signalsocket("TERM")
     1.8    multirand = require "multirand"
     1.9    execute.postfork_initializers()
    1.10  end
    1.11 @@ -340,9 +339,7 @@
    1.12  
    1.13  This function must be called in a configuration file (in the config/ directory) or in pre-fork initializers (in the app/_prefork/ or app/<application name>/_prefork/ directories), unless WebMCP is invoked in interactive mode (in which case any calls of listen{...} are ignored).
    1.14  
    1.15 -This function is a variant of Moonbridge's listen{...} function which has been wrapped for WebMCP. No "prepare", "conenct", or "finish" handler can be set. Instead WebMCP automatically dispatches incoming connections. For interval timers and main routines, a handler may be specified in each listener.
    1.16 -
    1.17 -Handlers for main routines (proto = "main") get a poll function passed as first and only parameter. This poll function behaves like moonbridge_io.poll(...) with the exeception that the return value is "terminate", "timeout", or "io" depending whether a termination is requested, a timeout happened, or data is ready for I/O.
    1.18 +This function is a variant of Moonbridge's listen{...} function which has been wrapped for WebMCP. No "prepare", "conenct", or "finish" handler can be set. Instead WebMCP automatically dispatches incoming connections. For interval timers and main routines, a handler may be specified in each listener. If a main handler returns, the WebMCP system will shut down.
    1.19  
    1.20  --]]--
    1.21  -- prepare for interactive or listen mode
    1.22 @@ -391,20 +388,7 @@
    1.23      args.connect = function(socket)
    1.24        if socket.main then
    1.25          request.initialize()
    1.26 -        local function poll(input_set, output_set, timeout)
    1.27 -          local input_set_copy = table.new(input_set)
    1.28 -          input_set_copy[sigterm_socket] = true
    1.29 -          local timeout = not moonbridge_io.poll(input_set_copy, output_set, timeout)
    1.30 -          local terminate = #(assert(sigterm_socket:read_nb())) > 0
    1.31 -          if terminate then
    1.32 -            return "terminate"
    1.33 -          elseif timeout then
    1.34 -            return "timeout"
    1.35 -          else
    1.36 -            return "io"
    1.37 -          end
    1.38 -        end
    1.39 -        main_handlers[socket.main](poll)
    1.40 +        main_handlers[socket.main]()
    1.41          io.stderr:write('Main handler "' .. socket.main .. '" terminated. Requesting shutdown.\n')
    1.42          return false
    1.43        elseif socket.interval then

Impressum / About Us