2.0 - support 'cache_acl' option

This commit is contained in:
Feng Lee 2016-07-21 17:51:02 +08:00
parent 0dbbe7d0df
commit 9555b0bf05
1 changed files with 7 additions and 4 deletions

View File

@ -397,13 +397,16 @@ validate_qos(_) ->
%% PUBLISH ACL is cached in process dictionary.
check_acl(publish, Topic, Client) ->
case get({acl, publish, Topic}) of
undefined ->
IfCache = emqttd:conf(cache_acl, true),
case {IfCache, get({acl, publish, Topic})} of
{true, undefined} ->
AllowDeny = emqttd_access_control:check_acl(Client, publish, Topic),
put({acl, publish, Topic}, AllowDeny),
AllowDeny;
AllowDeny ->
AllowDeny
{true, AllowDeny} ->
AllowDeny;
{false, _} ->
emqttd_access_control:check_acl(Client, publish, Topic)
end;
check_acl(subscribe, Topic, Client) ->