25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Fix select_type race on plugin_init

This commit is contained in:
Christophe Romain 2017-11-15 19:04:47 +01:00
parent e706e24b92
commit 62aab0fce4

View File

@ -3075,7 +3075,7 @@ get_configure(Host, ServerHost, Node, From, Lang) ->
-spec get_default(host(), binary(), jid(), binary()) -> {result, pubsub_owner()}. -spec get_default(host(), binary(), jid(), binary()) -> {result, pubsub_owner()}.
get_default(Host, Node, _From, Lang) -> get_default(Host, Node, _From, Lang) ->
Type = select_type(Host, Host, Node), Type = select_type(serverhost(Host), Host, Node),
Options = node_options(Host, Type), Options = node_options(Host, Type),
Fs = get_configure_xfields(Type, Options, Lang, []), Fs = get_configure_xfields(Type, Options, Lang, []),
{result, #pubsub_owner{default = {<<>>, #xdata{type = form, fields = Fs}}}}. {result, #pubsub_owner{default = {<<>>, #xdata{type = form, fields = Fs}}}}.
@ -3415,20 +3415,20 @@ config(ServerHost, Key, Default) ->
end. end.
-spec select_type(binary(), host(), binary(), binary()) -> binary(). -spec select_type(binary(), host(), binary(), binary()) -> binary().
select_type(ServerHost, Host, Node, Type) -> select_type(ServerHost, {_User, _Server, _Resource}, Node, _Type) ->
SelectedType = case Host of
{_User, _Server, _Resource} ->
case config(ServerHost, pep_mapping) of case config(ServerHost, pep_mapping) of
undefined -> ?PEPNODE; undefined -> ?PEPNODE;
Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE) Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE)
end; end;
_ -> select_type(ServerHost, _Host, _Node, Type) ->
Type case config(ServerHost, plugins) of
end, undefined ->
ConfiguredTypes = plugins(Host), Type;
case lists:member(SelectedType, ConfiguredTypes) of Plugins ->
true -> SelectedType; case lists:member(Type, Plugins) of
false -> hd(ConfiguredTypes) true -> Type;
false -> hd(Plugins)
end
end. end.
-spec select_type(binary(), host(), binary()) -> binary(). -spec select_type(binary(), host(), binary()) -> binary().