mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Don't retain module option on gen_mod supervisor
When module's options were updated (e.g. by reloading ejabberd.yml) and, later, the module's process crashed, gen_mod supervisor restarts the process with outdated options. This is now fixed.
This commit is contained in:
parent
e8fb9ab303
commit
2168489ddf
@ -101,8 +101,9 @@ depends(_Host, _Opts) ->
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
Mod:init(Host, Opts),
|
||||
init_cache(Mod, Host, Opts),
|
||||
|
@ -263,8 +263,9 @@ reload(Host, NewOpts, OldOpts) ->
|
||||
end,
|
||||
init_cache(NewMod, Host, NewOpts).
|
||||
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
init_cache(Mod, Host, Opts),
|
||||
Mod:init(Host, Opts),
|
||||
|
@ -135,7 +135,7 @@ disco_sm_identity(Acc, From, To, Node, Lang) ->
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
init([Host, _Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
catch ets:new(?MODULE,
|
||||
[named_table, public,
|
||||
|
@ -128,7 +128,7 @@ depends(_Host, _Opts) ->
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
init([Host, _Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
ejabberd_hooks:add(c2s_auth_result, Host, ?MODULE, c2s_auth_result, 100),
|
||||
ejabberd_hooks:add(c2s_stream_started, Host, ?MODULE, c2s_stream_started, 100),
|
||||
|
@ -110,7 +110,8 @@ depends(_Host, _Opts) ->
|
||||
%% {stop, Reason}
|
||||
%% Description: Initiates the server
|
||||
%%--------------------------------------------------------------------
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
try initialize(Host, Opts) of
|
||||
State ->
|
||||
process_flag(trap_exit, true),
|
||||
|
@ -230,8 +230,9 @@ depends(_Host, _Opts) ->
|
||||
%% gen_server callbacks.
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init(list()) -> {ok, state()}.
|
||||
init([ServerHost, Opts]) ->
|
||||
init([ServerHost|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(ServerHost, ?MODULE),
|
||||
Hosts = gen_mod:get_opt_hosts(Opts),
|
||||
Name = mod_http_upload_opt:name(Opts),
|
||||
Access = mod_http_upload_opt:access(Opts),
|
||||
|
@ -100,8 +100,9 @@ depends(_Host, _Opts) ->
|
||||
%% gen_server callbacks.
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init(list()) -> {ok, state()}.
|
||||
init([ServerHost, Opts]) ->
|
||||
init([ServerHost|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(ServerHost, ?MODULE),
|
||||
AccessSoftQuota = mod_http_upload_quota_opt:access_soft_quota(Opts),
|
||||
AccessHardQuota = mod_http_upload_quota_opt:access_hard_quota(Opts),
|
||||
MaxDays = mod_http_upload_quota_opt:max_days(Opts),
|
||||
|
@ -251,8 +251,9 @@ process_mam_query(IQ) ->
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
MyHosts = gen_mod:get_opt_hosts(Opts),
|
||||
case Mod:init(Host, gen_mod:set_opt(hosts, MyHosts, Opts)) of
|
||||
|
@ -164,7 +164,8 @@ select_retained({_, S, _} = USR, TopicFilter, QoS, SubID) ->
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
RMod = gen_mod:ram_db_mod(Opts, ?MODULE),
|
||||
try
|
||||
|
@ -34,7 +34,7 @@
|
||||
%% API
|
||||
-export([start/2,
|
||||
stop/1,
|
||||
start_link/3,
|
||||
start_link/2,
|
||||
reload/3,
|
||||
room_destroyed/4,
|
||||
store_room/4,
|
||||
@ -114,7 +114,7 @@
|
||||
%% API
|
||||
%%====================================================================
|
||||
start(Host, Opts) ->
|
||||
case mod_muc_sup:start(Host, Opts) of
|
||||
case mod_muc_sup:start(Host) of
|
||||
{ok, _} ->
|
||||
MyHosts = gen_mod:get_opt_hosts(Opts),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
@ -171,9 +171,9 @@ reload(ServerHost, NewOpts, OldOpts) ->
|
||||
depends(_Host, _Opts) ->
|
||||
[{mod_mam, soft}].
|
||||
|
||||
start_link(Host, Opts, I) ->
|
||||
start_link(Host, I) ->
|
||||
Proc = procname(Host, I),
|
||||
?GEN_SERVER:start_link({local, Proc}, ?MODULE, [Host, Opts, I],
|
||||
?GEN_SERVER:start_link({local, Proc}, ?MODULE, [Host, I],
|
||||
ejabberd_config:fsm_limit_opts([])).
|
||||
|
||||
-spec procname(binary(), pos_integer() | {binary(), binary()}) -> atom().
|
||||
@ -365,8 +365,9 @@ get_online_rooms_by_user(ServerHost, LUser, LServer) ->
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
-spec init(list()) -> {ok, state()}.
|
||||
init([Host, Opts, Worker]) ->
|
||||
init([Host, Worker]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
MyHosts = gen_mod:get_opt_hosts(Opts),
|
||||
register_routes(Host, MyHosts, Worker),
|
||||
register_iq_handlers(MyHosts, Worker),
|
||||
|
@ -96,8 +96,9 @@ depends(_Host, _Opts) ->
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
{ok, init_state(Host, Opts)}.
|
||||
|
||||
handle_call({check_access_log, ServerHost, FromJID}, _From, State) ->
|
||||
|
@ -23,25 +23,25 @@
|
||||
-behaviour(supervisor).
|
||||
|
||||
%% API
|
||||
-export([start/2, start_link/2, procname/1]).
|
||||
-export([start/1, start_link/1, procname/1]).
|
||||
%% Supervisor callbacks
|
||||
-export([init/1]).
|
||||
|
||||
%%%===================================================================
|
||||
%%% API functions
|
||||
%%%===================================================================
|
||||
start(Host, Opts) ->
|
||||
start(Host) ->
|
||||
Spec = #{id => procname(Host),
|
||||
start => {?MODULE, start_link, [Host, Opts]},
|
||||
start => {?MODULE, start_link, [Host]},
|
||||
restart => permanent,
|
||||
shutdown => infinity,
|
||||
type => supervisor,
|
||||
modules => [?MODULE]},
|
||||
supervisor:start_child(ejabberd_gen_mod_sup, Spec).
|
||||
|
||||
start_link(Host, Opts) ->
|
||||
start_link(Host) ->
|
||||
Proc = procname(Host),
|
||||
supervisor:start_link({local, Proc}, ?MODULE, [Host, Opts]).
|
||||
supervisor:start_link({local, Proc}, ?MODULE, [Host]).
|
||||
|
||||
-spec procname(binary()) -> atom().
|
||||
procname(Host) ->
|
||||
@ -50,12 +50,12 @@ procname(Host) ->
|
||||
%%%===================================================================
|
||||
%%% Supervisor callbacks
|
||||
%%%===================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host]) ->
|
||||
Cores = erlang:system_info(logical_processors),
|
||||
Specs = lists:foldl(
|
||||
fun(I, Acc) ->
|
||||
[#{id => mod_muc:procname(Host, I),
|
||||
start => {mod_muc, start_link, [Host, Opts, I]},
|
||||
start => {mod_muc, start_link, [Host, I]},
|
||||
restart => permanent,
|
||||
shutdown => timer:minutes(1),
|
||||
type => worker,
|
||||
|
@ -151,8 +151,9 @@ user_send_packet(Acc) ->
|
||||
%%====================================================================
|
||||
|
||||
-spec init(list()) -> {ok, state()}.
|
||||
init([LServerS, Opts]) ->
|
||||
init([LServerS|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(LServerS, ?MODULE),
|
||||
[LServiceS|_] = gen_mod:get_opt_hosts(Opts),
|
||||
Access = mod_multicast_opt:access(Opts),
|
||||
SLimits = build_service_limit_record(mod_multicast_opt:limits(Opts)),
|
||||
|
@ -91,8 +91,9 @@ reload(Host, NewOpts, OldOpts) ->
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
State = init_state(Host, Opts),
|
||||
register_iq_handlers(Host),
|
||||
case State#state.send_pings of
|
||||
|
@ -198,7 +198,7 @@ process_presence_in(Acc) ->
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
init([Host, _Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
catch ets:new(?MODULE,
|
||||
[named_table, public,
|
||||
|
@ -39,7 +39,7 @@
|
||||
%% supervisor callbacks.
|
||||
-export([init/1]).
|
||||
|
||||
-export([start_link/2, mod_opt_type/1, mod_options/1, depends/2]).
|
||||
-export([start_link/1, mod_opt_type/1, mod_options/1, depends/2]).
|
||||
|
||||
-define(PROCNAME, ejabberd_mod_proxy65).
|
||||
|
||||
@ -59,7 +59,7 @@ start(Host, Opts) ->
|
||||
Mod = gen_mod:ram_db_mod(global, ?MODULE),
|
||||
Mod:init(),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
ChildSpec = {Proc, {?MODULE, start_link, [Host, Opts]},
|
||||
ChildSpec = {Proc, {?MODULE, start_link, [Host]},
|
||||
transient, infinity, supervisor, [?MODULE]},
|
||||
supervisor:start_child(ejabberd_gen_mod_sup, ChildSpec)
|
||||
end.
|
||||
@ -80,14 +80,13 @@ reload(Host, NewOpts, OldOpts) ->
|
||||
Mod:init(),
|
||||
mod_proxy65_service:reload(Host, NewOpts, OldOpts).
|
||||
|
||||
start_link(Host, Opts) ->
|
||||
start_link(Host) ->
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
supervisor:start_link({local, Proc}, ?MODULE,
|
||||
[Host, Opts]).
|
||||
supervisor:start_link({local, Proc}, ?MODULE, [Host]).
|
||||
|
||||
init([Host, Opts]) ->
|
||||
init([Host]) ->
|
||||
Service = {mod_proxy65_service,
|
||||
{mod_proxy65_service, start_link, [Host, Opts]},
|
||||
{mod_proxy65_service, start_link, [Host]},
|
||||
transient, 5000, worker, [mod_proxy65_service]},
|
||||
{ok, {{one_for_one, 10, 1}, [Service]}}.
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
-export([init/1, handle_info/2, handle_call/3,
|
||||
handle_cast/2, terminate/2, code_change/3]).
|
||||
|
||||
-export([start_link/2, reload/3, add_listener/2, process_disco_info/1,
|
||||
-export([start_link/1, reload/3, add_listener/2, process_disco_info/1,
|
||||
process_disco_items/1, process_vcard/1, process_bytestreams/1,
|
||||
delete_listener/1, route/1]).
|
||||
|
||||
@ -50,17 +50,17 @@
|
||||
%%% gen_server callbacks
|
||||
%%%------------------------
|
||||
|
||||
start_link(Host, Opts) ->
|
||||
start_link(Host) ->
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:start_link({local, Proc}, ?MODULE,
|
||||
[Host, Opts], []).
|
||||
gen_server:start_link({local, Proc}, ?MODULE, [Host], []).
|
||||
|
||||
reload(Host, NewOpts, OldOpts) ->
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {reload, Host, NewOpts, OldOpts}).
|
||||
|
||||
init([Host, Opts]) ->
|
||||
init([Host]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, mod_proxy65),
|
||||
MyHosts = gen_mod:get_opt_hosts(Opts),
|
||||
lists:foreach(
|
||||
fun(MyHost) ->
|
||||
|
@ -241,9 +241,9 @@ stop(Host) ->
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init([binary() | [{_,_}],...]) -> {'ok',state()}.
|
||||
|
||||
init([ServerHost, Opts]) ->
|
||||
init([ServerHost|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
?DEBUG("Pubsub init ~p ~p", [ServerHost, Opts]),
|
||||
Opts = gen_mod:get_module_opts(ServerHost, ?MODULE),
|
||||
Hosts = gen_mod:get_opt_hosts(Opts),
|
||||
Access = mod_pubsub_opt:access_createnode(Opts),
|
||||
PepOffline = mod_pubsub_opt:ignore_pep_from_offline(Opts),
|
||||
|
@ -210,8 +210,9 @@ process_subscription(Direction, User, Server, JID,
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
State = parse_options(Host, Opts),
|
||||
init_cache(Host, Opts),
|
||||
ejabberd_hooks:add(roster_get, Host, ?MODULE,
|
||||
|
@ -82,8 +82,9 @@ stop(Host) ->
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
init([Host, Opts]) ->
|
||||
init([Host|_]) ->
|
||||
process_flag(trap_exit, true),
|
||||
Opts = gen_mod:get_module_opts(Host, ?MODULE),
|
||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||
Mod:init(Host, Opts),
|
||||
init_cache(Mod, Host, Opts),
|
||||
|
Loading…
Reference in New Issue
Block a user