mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Add gen_mod:is_loaded_elsewhere/2
This commit is contained in:
parent
b8fbac72ac
commit
0124d292b5
@ -37,7 +37,7 @@
|
||||
get_opt/4, get_opt_host/3, opt_type/1, is_equal_opt/5,
|
||||
get_module_opt/4, get_module_opt/5, get_module_opt_host/3,
|
||||
loaded_modules/1, loaded_modules_with_opts/1,
|
||||
get_hosts/2, get_module_proc/2, is_loaded/2,
|
||||
get_hosts/2, get_module_proc/2, is_loaded/2, is_loaded_elsewhere/2,
|
||||
start_modules/0, start_modules/1, stop_modules/0, stop_modules/1,
|
||||
db_mod/2, db_mod/3, ram_db_mod/2, ram_db_mod/3,
|
||||
db_type/2, db_type/3, ram_db_type/2, ram_db_type/3]).
|
||||
@ -622,6 +622,15 @@ get_module_proc(Host, Base) ->
|
||||
is_loaded(Host, Module) ->
|
||||
ets:member(ejabberd_modules, {Module, Host}).
|
||||
|
||||
-spec is_loaded_elsewhere(binary(), atom()) -> boolean().
|
||||
is_loaded_elsewhere(Host, Module) ->
|
||||
ets:select_count(
|
||||
ejabberd_modules,
|
||||
ets:fun2ms(
|
||||
fun(#ejabberd_module{module_host = {Mod, H}}) ->
|
||||
(Mod == Module) and (H /= Host)
|
||||
end)) /= 0.
|
||||
|
||||
-spec config_reloaded() -> ok.
|
||||
config_reloaded() ->
|
||||
lists:foreach(
|
||||
|
@ -150,7 +150,7 @@ handle_info(_Info, State) ->
|
||||
terminate(_Reason, #state{host = Host}) ->
|
||||
ejabberd_hooks:delete(c2s_auth_result, Host, ?MODULE, c2s_auth_result, 100),
|
||||
ejabberd_hooks:delete(c2s_stream_started, Host, ?MODULE, c2s_stream_started, 100),
|
||||
case is_loaded_at_other_hosts(Host) of
|
||||
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
@ -184,14 +184,6 @@ is_whitelisted(Host, Addr) ->
|
||||
none),
|
||||
acl:match_rule(Host, Access, Addr) == allow.
|
||||
|
||||
is_loaded_at_other_hosts(Host) ->
|
||||
lists:any(
|
||||
fun(VHost) when VHost == Host ->
|
||||
false;
|
||||
(VHost) ->
|
||||
gen_mod:is_loaded(VHost, ?MODULE)
|
||||
end, ?MYHOSTS).
|
||||
|
||||
seconds_to_now(Secs) ->
|
||||
{Secs div 1000000, Secs rem 1000000, 0}.
|
||||
|
||||
|
@ -63,7 +63,12 @@ start(Host, Opts) ->
|
||||
end.
|
||||
|
||||
stop(Host) ->
|
||||
mod_proxy65_service:delete_listener(Host),
|
||||
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
||||
false ->
|
||||
mod_proxy65_service:delete_listener(Host);
|
||||
true ->
|
||||
ok
|
||||
end,
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
supervisor:terminate_child(ejabberd_gen_mod_sup, Proc),
|
||||
supervisor:delete_child(ejabberd_gen_mod_sup, Proc).
|
||||
|
Loading…
Reference in New Issue
Block a user