# HG changeset patch # User Marco Cirillo # Date 1326763116 0 # Node ID f2ec7149b0057c97a4060e29dfe5fd669e740645 # Parent b62f5e38f865d354681f50bd01b151c58a61e62c mod_register_json: reworked the ccleanup function so that it doesn' try to close an unused listener port if server_event is in use (works only with select) diff -r b62f5e38f865 -r f2ec7149b005 mod_register_json/mod_register_json.lua --- a/mod_register_json/mod_register_json.lua Tue Jan 17 00:57:47 2012 +0000 +++ b/mod_register_json/mod_register_json.lua Tue Jan 17 01:18:36 2012 +0000 @@ -124,15 +124,19 @@ end end - -- if there're no handlers left clean the socket, not sure if it works with server_select - for _, options in ipairs(ports) do - if options.port and not next(httpserver.new.http_servers[options.port].handlers) then - httpserver.new.http_servers[options.port] = nil - if options.interface then - for _, value in ipairs(options.interface) do - if server.getserver(value, options.port) then server.removeserver(value, options.port) end - end - else if server.getserver("*", options.port) then server.removeserver("*", options.port) end end + -- if there are no handlers left clean and close the socket, doesn't work with server_event + local event = module:get_option_boolean("use_libevent", nil) + + if not event then + for _, options in ipairs(ports) do + if options.port and not next(httpserver.new.http_servers[options.port].handlers) then + httpserver.new.http_servers[options.port] = nil + if options.interface then + for _, value in ipairs(options.interface) do + if server.getserver(value, options.port) then server.removeserver(value, options.port) end + end + else if server.getserver("*", options.port) then server.removeserver("*", options.port) end end + end end end