From: Evgeny Khramtsov Date: Thu, 18 Jul 2019 09:47:29 +0000 (+0300) Subject: Reset net ticktime on config reload X-Git-Tag: 19.08~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6397dc5d4c3d4cfe44612bd7f4401ed520aa31a0;p=ejabberd Reset net ticktime on config reload --- diff --git a/src/ejabberd_cluster.erl b/src/ejabberd_cluster.erl index c238efc10..9cb189248 100644 --- a/src/ejabberd_cluster.erl +++ b/src/ejabberd_cluster.erl @@ -32,6 +32,8 @@ %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). +%% hooks +-export([set_ticktime/0]). -include("logger.hrl"). @@ -156,19 +158,26 @@ subscribe(Proc) -> Mod = get_mod(), Mod:subscribe(Proc). +%%%=================================================================== +%%% Hooks +%%%=================================================================== +set_ticktime() -> + Ticktime = ejabberd_option:net_ticktime() div 1000, + net_kernel:set_net_ticktime(Ticktime). + %%%=================================================================== %%% gen_server API %%%=================================================================== init([]) -> - Ticktime = ejabberd_option:net_ticktime() div 1000, + set_ticktime(), Nodes = ejabberd_option:cluster_nodes(), - _ = net_kernel:set_net_ticktime(Ticktime), lists:foreach(fun(Node) -> net_kernel:connect_node(Node) end, Nodes), Mod = get_mod(), case Mod:init() of ok -> + ejabberd_hooks:add(config_reloaded, ?MODULE, set_ticktime, 50), Mod:subscribe(?MODULE), {ok, #state{}}; {error, Reason} -> @@ -194,7 +203,7 @@ handle_info(Info, State) -> {noreply, State}. terminate(_Reason, _State) -> - ok. + ejabberd_hooks:delete(config_reloaded, ?MODULE, set_ticktime, 50). code_change(_OldVsn, State, _Extra) -> {ok, State}.