mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Use the new gen_mod:prep_stop/1 feature
This fixes the problem when stopping the module with multiple vhosts: unsubscribing from a local pubsub requires mod_pubsub in that vhost running, but ejabberd stops mod_pubsub from a vhost before stopping mod_antispam in other vhost.
This commit is contained in:
parent
b65c11daf6
commit
c3f5083f15
1 changed files with 16 additions and 0 deletions
|
@ -35,6 +35,7 @@
|
|||
|
||||
%% gen_mod callbacks.
|
||||
-export([start/2,
|
||||
prep_stop/1,
|
||||
stop/1,
|
||||
reload/3,
|
||||
depends/2,
|
||||
|
@ -104,6 +105,13 @@ start(Host, Opts) ->
|
|||
end,
|
||||
gen_mod:start_child(?MODULE, Host, Opts).
|
||||
|
||||
-spec prep_stop(binary()) -> ok | {error, any()}.
|
||||
prep_stop(Host) ->
|
||||
case try_call_by_host(Host, prepare_stop) of
|
||||
ready_to_stop ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec stop(binary()) -> ok | {error, any()}.
|
||||
stop(Host) ->
|
||||
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
||||
|
@ -317,6 +325,14 @@ handle_call({is_blocked_domain, Domain},
|
|||
{reply,
|
||||
maps:get(Domain, maps:merge(BlockedDomains, WhitelistDomains), false) =/= false,
|
||||
State};
|
||||
handle_call(prepare_stop,
|
||||
_From,
|
||||
#state{host = Host,
|
||||
rtbl_host = RTBLHost,
|
||||
rtbl_domains_node = RTBLDomainsNode} =
|
||||
State) ->
|
||||
mod_antispam_rtbl:unsubscribe(RTBLHost, RTBLDomainsNode, Host),
|
||||
{reply, ready_to_stop, State};
|
||||
handle_call(Request, From, State) ->
|
||||
?ERROR_MSG("Got unexpected request from ~p: ~p", [From, Request]),
|
||||
{noreply, State}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue