Software /
code /
prosody-modules
Diff
mod_register_json/mod_register_json.lua @ 561:f2ec7149b005
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)
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Tue, 17 Jan 2012 01:18:36 +0000 |
parent | 560:b62f5e38f865 |
child | 563:cd5581b58fdc |
line wrap: on
line diff
--- 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