From 9555b0bf055a264c4ff7f040c15129af79999dfc Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Thu, 21 Jul 2016 17:51:02 +0800 Subject: [PATCH] 2.0 - support 'cache_acl' option --- src/emqttd_protocol.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/emqttd_protocol.erl b/src/emqttd_protocol.erl index 7c8a87146..63a6ec821 100644 --- a/src/emqttd_protocol.erl +++ b/src/emqttd_protocol.erl @@ -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) ->