webmcp

changeset 473:981ebb743b36

Support proto = "main" in listen{...} call
author jbe
date Tue Jun 06 11:36:31 2017 +0200 (12 months ago)
parents 07e7e218d8df
children d1c16b6611dd
files framework/bin/mcp.lua
line diff
     1.1 --- a/framework/bin/mcp.lua	Sun May 28 00:30:10 2017 +0200
     1.2 +++ b/framework/bin/mcp.lua	Tue Jun 06 11:36:31 2017 +0200
     1.3 @@ -352,9 +352,17 @@
     1.4      assert(args, "No argument passed to listen function")
     1.5      local min_requests_per_fork = args.min_requests_per_fork or 50
     1.6      local max_requests_per_fork = args.max_requests_per_fork or 200
     1.7 +    local main_handlers = {}
     1.8      local interval_handlers = {}
     1.9      for j, listener in ipairs(args) do
    1.10 -      if listener.proto == "interval" then
    1.11 +      if listener.proto == "main" then
    1.12 +        local name = listener.name or "Unnamed main thread #" .. #main_handlers+1
    1.13 +        if main_handlers[name] ~= nil then
    1.14 +          error('Main thread handler with duplicate name "' .. name .. '"')
    1.15 +        end
    1.16 +        main_handlers[name] = listener.handler
    1.17 +        listener.name = name
    1.18 +      elseif listener.proto == "interval" then
    1.19          local name = listener.name or "Unnamed interval #" .. #interval_handlers+1
    1.20          if interval_handlers[name] ~= nil then
    1.21            error('Interval handler with duplicate name "' .. name .. '"')
    1.22 @@ -375,7 +383,11 @@
    1.23      local outer_handler = http.generate_handler(inner_handler, args.http_options)
    1.24      args.prepare = postfork_init
    1.25      args.connect = function(socket)
    1.26 -      if socket.interval then
    1.27 +      if socket.main then
    1.28 +        request.initialize()
    1.29 +        main_handlers[socket.main]()
    1.30 +        return false
    1.31 +      elseif socket.interval then
    1.32          request_count = request_count + 1
    1.33          request.initialize()
    1.34          interval_handlers[socket.interval]()

Impressum / About Us