25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Reset net ticktime on config reload

This commit is contained in:
Evgeny Khramtsov 2019-07-18 12:47:29 +03:00
parent dd301306d3
commit 6397dc5d4c

View File

@ -32,6 +32,8 @@
%% gen_server callbacks %% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
%% hooks
-export([set_ticktime/0]).
-include("logger.hrl"). -include("logger.hrl").
@ -156,19 +158,26 @@ subscribe(Proc) ->
Mod = get_mod(), Mod = get_mod(),
Mod:subscribe(Proc). Mod:subscribe(Proc).
%%%===================================================================
%%% Hooks
%%%===================================================================
set_ticktime() ->
Ticktime = ejabberd_option:net_ticktime() div 1000,
net_kernel:set_net_ticktime(Ticktime).
%%%=================================================================== %%%===================================================================
%%% gen_server API %%% gen_server API
%%%=================================================================== %%%===================================================================
init([]) -> init([]) ->
Ticktime = ejabberd_option:net_ticktime() div 1000, set_ticktime(),
Nodes = ejabberd_option:cluster_nodes(), Nodes = ejabberd_option:cluster_nodes(),
_ = net_kernel:set_net_ticktime(Ticktime),
lists:foreach(fun(Node) -> lists:foreach(fun(Node) ->
net_kernel:connect_node(Node) net_kernel:connect_node(Node)
end, Nodes), end, Nodes),
Mod = get_mod(), Mod = get_mod(),
case Mod:init() of case Mod:init() of
ok -> ok ->
ejabberd_hooks:add(config_reloaded, ?MODULE, set_ticktime, 50),
Mod:subscribe(?MODULE), Mod:subscribe(?MODULE),
{ok, #state{}}; {ok, #state{}};
{error, Reason} -> {error, Reason} ->
@ -194,7 +203,7 @@ handle_info(Info, State) ->
{noreply, State}. {noreply, State}.
terminate(_Reason, _State) -> terminate(_Reason, _State) ->
ok. ejabberd_hooks:delete(config_reloaded, ?MODULE, set_ticktime, 50).
code_change(_OldVsn, State, _Extra) -> code_change(_OldVsn, State, _Extra) ->
{ok, State}. {ok, State}.