# HG changeset patch # User jbe # Date 1497137545 -7200 # Node ID 5b0066fd326efa873b44f04c2ca951186142ced1 # Parent 87c87be92154f44a4bf301a062f630f8e0873457 Removed termination handling from WebMCP (to be done by moonbridge_io if needed) diff -r 87c87be92154 -r 5b0066fd326e framework/bin/mcp.lua --- a/framework/bin/mcp.lua Fri Jun 09 18:19:15 2017 +0200 +++ b/framework/bin/mcp.lua Sun Jun 11 01:32:25 2017 +0200 @@ -286,7 +286,6 @@ -- define post-fork initialization function (including loading of "multirand" library) local function postfork_init() - sigterm_socket = moonbridge_io.signalsocket("TERM") multirand = require "multirand" execute.postfork_initializers() end @@ -340,9 +339,7 @@ This function must be called in a configuration file (in the config/ directory) or in pre-fork initializers (in the app/_prefork/ or app//_prefork/ directories), unless WebMCP is invoked in interactive mode (in which case any calls of listen{...} are ignored). -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. - -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. +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. --]]-- -- prepare for interactive or listen mode @@ -391,20 +388,7 @@ args.connect = function(socket) if socket.main then request.initialize() - local function poll(input_set, output_set, timeout) - local input_set_copy = table.new(input_set) - input_set_copy[sigterm_socket] = true - local timeout = not moonbridge_io.poll(input_set_copy, output_set, timeout) - local terminate = #(assert(sigterm_socket:read_nb())) > 0 - if terminate then - return "terminate" - elseif timeout then - return "timeout" - else - return "io" - end - end - main_handlers[socket.main](poll) + main_handlers[socket.main]() io.stderr:write('Main handler "' .. socket.main .. '" terminated. Requesting shutdown.\n') return false elseif socket.interval then