Handle ets_cache return value in shared roster get_group_opts (#3296)
This commit is contained in:
parent
266691f929
commit
7efc208b9e
|
@ -448,7 +448,7 @@ delete_group(Host, Group) ->
|
||||||
get_group_opts(Host1, Group1) ->
|
get_group_opts(Host1, Group1) ->
|
||||||
{Host, Group} = split_grouphost(Host1, Group1),
|
{Host, Group} = split_grouphost(Host1, Group1),
|
||||||
Mod = gen_mod:db_mod(Host, ?MODULE),
|
Mod = gen_mod:db_mod(Host, ?MODULE),
|
||||||
case use_cache(Mod, Host) of
|
Res = case use_cache(Mod, Host) of
|
||||||
true ->
|
true ->
|
||||||
ets_cache:lookup(
|
ets_cache:lookup(
|
||||||
?GROUP_OPTS_CACHE, {Host, Group},
|
?GROUP_OPTS_CACHE, {Host, Group},
|
||||||
|
@ -460,6 +460,10 @@ get_group_opts(Host1, Group1) ->
|
||||||
end);
|
end);
|
||||||
false ->
|
false ->
|
||||||
Mod:get_group_opts(Host, Group)
|
Mod:get_group_opts(Host, Group)
|
||||||
|
end,
|
||||||
|
case Res of
|
||||||
|
{ok, Opts} -> Opts;
|
||||||
|
error -> error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_group_opts(Host, Group, Opts) ->
|
set_group_opts(Host, Group, Opts) ->
|
||||||
|
|
|
@ -87,7 +87,7 @@ delete_group(Host, Group) ->
|
||||||
|
|
||||||
get_group_opts(Host, Group) ->
|
get_group_opts(Host, Group) ->
|
||||||
case catch mnesia:dirty_read(sr_group, {Group, Host}) of
|
case catch mnesia:dirty_read(sr_group, {Group, Host}) of
|
||||||
[#sr_group{opts = Opts}] -> Opts;
|
[#sr_group{opts = Opts}] -> {ok, Opts};
|
||||||
_ -> error
|
_ -> error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ get_group_opts(Host, Group) ->
|
||||||
?SQL("select @(opts)s from sr_group"
|
?SQL("select @(opts)s from sr_group"
|
||||||
" where name=%(Group)s and %(Host)H")) of
|
" where name=%(Group)s and %(Host)H")) of
|
||||||
{selected, [{SOpts}]} ->
|
{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
|
_ -> error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue