Handle ets_cache return value in shared roster get_group_opts (#3296)

This commit is contained in:
Badlop 2020-06-05 19:32:35 +02:00
parent 266691f929
commit 7efc208b9e
3 changed files with 7 additions and 3 deletions

View File

@ -448,7 +448,7 @@ delete_group(Host, Group) ->
get_group_opts(Host1, Group1) ->
{Host, Group} = split_grouphost(Host1, Group1),
Mod = gen_mod:db_mod(Host, ?MODULE),
case use_cache(Mod, Host) of
Res = case use_cache(Mod, Host) of
true ->
ets_cache:lookup(
?GROUP_OPTS_CACHE, {Host, Group},
@ -460,6 +460,10 @@ get_group_opts(Host1, Group1) ->
end);
false ->
Mod:get_group_opts(Host, Group)
end,
case Res of
{ok, Opts} -> Opts;
error -> error
end.
set_group_opts(Host, Group, Opts) ->

View File

@ -87,7 +87,7 @@ delete_group(Host, Group) ->
get_group_opts(Host, Group) ->
case catch mnesia:dirty_read(sr_group, {Group, Host}) of
[#sr_group{opts = Opts}] -> Opts;
[#sr_group{opts = Opts}] -> {ok, Opts};
_ -> error
end.

View File

@ -94,7 +94,7 @@ get_group_opts(Host, Group) ->
?SQL("select @(opts)s from sr_group"
" where name=%(Group)s and %(Host)H")) of
{selected, [{SOpts}]} ->
mod_shared_roster:opts_to_binary(ejabberd_sql:decode_term(SOpts));
{ok, mod_shared_roster:opts_to_binary(ejabberd_sql:decode_term(SOpts))};
_ -> error
end.