Stop the bloom and normalize processes when stopping mod_pottymouth

This commit is contained in:
Badlop 2019-02-21 13:32:13 +01:00
parent bae1cdc52e
commit 009d25f0bd
3 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@
-export([member/1]).
%% gen_server callbacks
-export([start/1, stop/0, init/1, handle_call/3, handle_cast/2, handle_info/2,
-export([start/1, stop/1, init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
serverName(Lang) ->
@ -20,8 +20,8 @@ member({Lang, Word} = _MessageToken) ->
start({Lang, BlacklistFile} = _Opts) ->
gen_server:start_link({local, serverName(Lang)}, ?MODULE, [BlacklistFile], []).
stop() ->
ok.
stop({Lang, _BlacklistFile} = _Opts) ->
gen_server:stop(serverName(Lang)).
init([BlacklistFile]) ->
?INFO_MSG("Building bloom ~p~n", [BlacklistFile]),

View File

@ -67,9 +67,11 @@ start(_Host, Opts) ->
ejabberd_hooks:add(filter_packet, global, ?MODULE, on_filter_packet, 0),
ok.
stop(_Host) ->
bloom_gen_server:stop(),
normalize_leet_gen_server:stop(),
stop(Host) ->
Blacklists = gen_mod:get_module_opt(Host, ?MODULE, blacklists),
lists:map(fun bloom_gen_server:stop/1, Blacklists),
CharMaps = gen_mod:get_module_opt(Host, ?MODULE, charmaps),
lists:map(fun normalize_leet_gen_server:stop/1, CharMaps),
ejabberd_hooks:delete(filter_packet, global, ?MODULE, on_filter_packet, 0),
ok.

View File

@ -8,7 +8,7 @@
-export([normalize/1]).
%% gen_server callbacks
-export([start/1, stop/0, init/1, handle_call/3, handle_cast/2, handle_info/2,
-export([start/1, stop/1, init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
serverName(Lang) ->
@ -23,8 +23,8 @@ normalize({Lang, Word} = _MessageToken) ->
start({Lang, CharMapFile} = _Opts) ->
gen_server:start_link({local, serverName(Lang)}, ?MODULE, [CharMapFile], []).
stop() ->
ok.
stop({Lang, _CharMapFile} = _Opts) ->
gen_server:stop(serverName(Lang)).
init([CharMapFile]) ->
?INFO_MSG("NormalizeLeet Loading: ~p~n", [CharMapFile]),