Software /
code /
prosody
Changeset
7662:946871f6e3c8
mod_c2s, mod_s2s: Switch connection counting to 'amount' type and enumerate once per statistics interval
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Sep 2016 15:01:16 +0200 |
parents | 7659:449de852cf38 |
children | 7663:54424e981796 |
files | plugins/mod_c2s.lua plugins/mod_s2s/mod_s2s.lua |
diffstat | 2 files changed, 6 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Wed Sep 07 19:32:29 2016 +0100 +++ b/plugins/mod_c2s.lua Mon Sep 12 15:01:16 2016 +0200 @@ -27,7 +27,7 @@ local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); -local measure_connections = module:measure("connections", "counter"); +local measure_connections = module:measure("connections", "amount"); local sessions = module:shared("sessions"); local core_process_stanza = prosody.core_process_stanza; @@ -36,7 +36,7 @@ local stream_callbacks = { default_ns = "jabber:client" }; local listener = {}; -do +module:hook("stats-update", function () -- Connection counter resets to 0 on load and reload -- Bump it up to current value local count = 0; @@ -44,7 +44,7 @@ count = count + 1; end measure_connections(count); -end +end); --- Stream events handlers local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; @@ -207,7 +207,6 @@ --- Port listener function listener.onconnect(conn) - measure_connections(1); local session = sm_new_session(conn); sessions[conn] = session; @@ -276,7 +275,6 @@ end function listener.ondisconnect(conn, err) - measure_connections(-1); local session = sessions[conn]; if session then (session.log or log)("info", "Client disconnected: %s", err or "connection closed");
--- a/plugins/mod_s2s/mod_s2s.lua Wed Sep 07 19:32:29 2016 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Mon Sep 12 15:01:16 2016 +0200 @@ -37,13 +37,13 @@ module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; local require_encryption = module:get_option_boolean("s2s_require_encryption", false); -local measure_connections = module:measure("connections", "counter"); +local measure_connections = module:measure("connections", "amount"); local sessions = module:shared("sessions"); local log = module._log; -do +module:hook("stats-update", function () -- Connection counter resets to 0 on load and reload -- Bump it up to current value local count = 0; @@ -51,7 +51,7 @@ count = count + 1; end measure_connections(count); -end +end); --- Handle stanzas to remote domains @@ -588,7 +588,6 @@ end function listener.onconnect(conn) - measure_connections(1); conn:setoption("keepalive", opt_keepalives); local session = sessions[conn]; if not session then -- New incoming connection @@ -619,13 +618,7 @@ end end -function listener.ontimeout(conn) - -- Called instead of onconnect when the connection times out - measure_connections(1); -end - function listener.ondisconnect(conn, err) - measure_connections(-1); local session = sessions[conn]; if session then sessions[conn] = nil;