From 03cd4de6b0f50d674e0985a567e709fe0d7aa8c8 Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 31 Dec 2021 20:11:30 +0100 Subject: [PATCH] Set c2s_closed priority in mod_statsdx lower than in mod_stream_mgmt If c2s_closed reason is [{socket,ping_timeout}], mod_stream_mgmt stops the hook (see c2s_closed/2) and mod_statsdx doesn't notice the client disconnection. To reproduce: login with Xabber-Android, then disable Wifi in that mobile and wait for mod_ping to kill the connection. --- mod_statsdx/src/mod_statsdx.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod_statsdx/src/mod_statsdx.erl b/mod_statsdx/src/mod_statsdx.erl index 52a2b2a..d9c2b90 100644 --- a/mod_statsdx/src/mod_statsdx.erl +++ b/mod_statsdx/src/mod_statsdx.erl @@ -195,7 +195,7 @@ prepare_stats_host(Host, Hooks, CD) -> ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 90), ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 90), ejabberd_hooks:add(c2s_session_opened, Host, ?MODULE, user_login, 90), - ejabberd_hooks:add(c2s_closed, Host, ?MODULE, user_logout, 90), + ejabberd_hooks:add(c2s_closed, Host, ?MODULE, user_logout, 40), %%ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, user_logout_sm, 90), ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 90); traffic -> @@ -204,7 +204,7 @@ prepare_stats_host(Host, Hooks, CD) -> ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 90), ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 90), ejabberd_hooks:add(c2s_session_opened, Host, ?MODULE, user_login, 90), - ejabberd_hooks:add(c2s_closed, Host, ?MODULE, user_logout, 90), + ejabberd_hooks:add(c2s_closed, Host, ?MODULE, user_logout, 40), %%ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, user_logout_sm, 90), ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 90); false -> @@ -224,7 +224,7 @@ finish_stats() -> finish_stats(Host) -> ejabberd_hooks:delete(c2s_session_opened, Host, ?MODULE, user_login, 90), - ejabberd_hooks:delete(c2s_closed, Host, ?MODULE, user_logout, 90), + ejabberd_hooks:delete(c2s_closed, Host, ?MODULE, user_logout, 40), %%ejabberd_hooks:delete(sm_remove_connection_hook, Host, ?MODULE, user_logout_sm, 90), ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, user_send_packet, 90), ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, user_send_packet_traffic, 92),