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 case config(ServerHost, pep_mapping) of
{_User, _Server, _Resource} -> undefined -> ?PEPNODE;
case config(ServerHost, pep_mapping) of Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE)
undefined -> ?PEPNODE; end;
Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE) select_type(ServerHost, _Host, _Node, Type) ->
end; case config(ServerHost, plugins) of
_ -> undefined ->
Type Type;
end, Plugins ->
ConfiguredTypes = plugins(Host), case lists:member(Type, Plugins) of
case lists:member(SelectedType, ConfiguredTypes) of true -> Type;
true -> SelectedType; false -> hd(Plugins)
false -> hd(ConfiguredTypes) end
end. end.
-spec select_type(binary(), host(), binary()) -> binary(). -spec select_type(binary(), host(), binary()) -> binary().