From f2faca6dc92ffdb71a0f85e704ad21a9f133c18e Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sun, 14 Jul 2019 15:10:11 +0200 Subject: [PATCH] mod_spam_filter: Fix unregistration of global hook Don't unregister the 'reopen_log_hook' if the module is loaded for another host. --- mod_spam_filter/src/mod_spam_filter.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod_spam_filter/src/mod_spam_filter.erl b/mod_spam_filter/src/mod_spam_filter.erl index ef977ae..5d2cea1 100644 --- a/mod_spam_filter/src/mod_spam_filter.erl +++ b/mod_spam_filter/src/mod_spam_filter.erl @@ -265,12 +265,17 @@ terminate(Reason, #state{host = Host} = State) -> DumpFile = gen_mod:get_module_opt(Host, ?MODULE, spam_dump_file), DumpFile1 = expand_host(DumpFile, Host), close_dump_file(DumpFile1, State), - ejabberd_hooks:delete(reopen_log_hook, ?MODULE, - reopen_log, 50), ejabberd_hooks:delete(s2s_receive_packet, Host, ?MODULE, s2s_receive_packet, 50), ejabberd_hooks:delete(s2s_in_handle_info, Host, ?MODULE, - s2s_in_handle_info, 90). + s2s_in_handle_info, 90), + case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of + false -> + ejabberd_hooks:delete(reopen_log_hook, ?MODULE, + reopen_log, 50); + true -> + ok + end. -spec code_change({down, term()} | term(), state(), term()) -> {ok, state()}. code_change(_OldVsn, #state{host = Host} = State, _Extra) ->