From 009d25f0bd6b39022ef67a1dddc9fa852de9fd14 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 21 Feb 2019 13:32:13 +0100 Subject: [PATCH] Stop the bloom and normalize processes when stopping mod_pottymouth --- mod_pottymouth/src/bloom_gen_server.erl | 6 +++--- mod_pottymouth/src/mod_pottymouth.erl | 8 +++++--- mod_pottymouth/src/normalize_leet_gen_server.erl | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mod_pottymouth/src/bloom_gen_server.erl b/mod_pottymouth/src/bloom_gen_server.erl index 19abfc0..7b94466 100644 --- a/mod_pottymouth/src/bloom_gen_server.erl +++ b/mod_pottymouth/src/bloom_gen_server.erl @@ -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]), diff --git a/mod_pottymouth/src/mod_pottymouth.erl b/mod_pottymouth/src/mod_pottymouth.erl index 0dab4d2..cadd8e5 100644 --- a/mod_pottymouth/src/mod_pottymouth.erl +++ b/mod_pottymouth/src/mod_pottymouth.erl @@ -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. diff --git a/mod_pottymouth/src/normalize_leet_gen_server.erl b/mod_pottymouth/src/normalize_leet_gen_server.erl index 88818cf..bc5e121 100644 --- a/mod_pottymouth/src/normalize_leet_gen_server.erl +++ b/mod_pottymouth/src/normalize_leet_gen_server.erl @@ -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]),