Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
cacheseconds == 0 disables cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Piet Mens committed Nov 3, 2014
1 parent 6abfa82 commit a601506
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The following `auth_opt_` options are supported by the mysql back-end:
| mysql_opt_reconnect | true | | enable MYSQL_OPT_RECONNECT option
| mysql_auto_connect | true | | enable auto_connect function
| anonusername | | | username to use for anonymous connections
| cacheseconds | 300 | | number of seconds to cache ACL lookups
| cacheseconds | 300 | | number of seconds to cache ACL lookups. 0 disables

The SQL query for looking up a user's password hash is mandatory. The query
MUST return a single row only (any other number of rows is considered to be
Expand Down
7 changes: 7 additions & 0 deletions cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ void acl_cache(const char *clientid, const char *username, const char *topic, in
time_t cacheseconds = ud->cacheseconds;
time_t now;

if (ud->cacheseconds <= 0) {
return;
}

now = time(NULL);

hexify(clientid, username, topic, access, hex);
Expand Down Expand Up @@ -134,6 +138,9 @@ int cache_q(const char *clientid, const char *username, const char *topic, int a
time_t cacheseconds = ud->cacheseconds;
int granted = MOSQ_ERR_UNKNOWN;

if (ud->cacheseconds <= 0) {
return (MOSQ_ERR_UNKNOWN);
}
hexify(clientid, username, topic, access, hex);

HASH_FIND_STR(ud->aclcache, hex, a);
Expand Down

0 comments on commit a601506

Please sign in to comment.