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

Commit

Permalink
s/tics/seconds/g
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Piet Mens committed Nov 3, 2014
1 parent 368ff61 commit cad9e57
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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
| cachetics | 300 | | number of seconds to cache ACL lookups
| cacheseconds | 300 | | number of seconds to cache ACL lookups

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
6 changes: 3 additions & 3 deletions auth-plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int mosquitto_auth_plugin_init(void **userdata, struct mosquitto_auth_opt *auth_
ud->authentication_be = -1;
ud->fallback_be = -1;
ud->anonusername = NULL;
ud->cachetics = 300;
ud->cacheseconds = 300;
ud->aclcache = NULL;

/*
Expand All @@ -134,8 +134,8 @@ int mosquitto_auth_plugin_init(void **userdata, struct mosquitto_auth_opt *auth_
ud->superusers = strdup(o->value);
if (!strcmp(o->key, "anonusername"))
ud->anonusername = strdup(o->value);
if (!strcmp(o->key, "cachetics"))
ud->cachetics = atol(o->value);
if (!strcmp(o->key, "cacheseconds"))
ud->cacheseconds = atol(o->value);
#if 0
if (!strcmp(o->key, "topic_prefix"))
ud->topicprefix = strdup(o->value);
Expand Down
10 changes: 5 additions & 5 deletions cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ void acl_cache(const char *clientid, const char *username, const char *topic, in
char hex[SHA_DIGEST_LENGTH * 2 + 1];
struct aclcache *a;
struct userdata *ud = (struct userdata *)userdata;
time_t cachetics = ud->cachetics;
time_t cacheseconds = ud->cacheseconds;

hexify(clientid, username, topic, access, hex);

HASH_FIND_STR(ud->aclcache, hex, a);
if (a) {
granted = a->granted;

if (time(NULL) > (a->tics + cachetics)) {
if (time(NULL) > (a->seconds + cacheseconds)) {
printf("EXPIRED!!!!!!!!!!!!!\n");
HASH_DEL(ud->aclcache, a);
}
} else {
a = (struct aclcache *)malloc(sizeof(struct aclcache));
strcpy(a->hex, hex);
a->granted = granted;
a->tics = time(NULL);
a->seconds = time(NULL);
HASH_ADD_STR(ud->aclcache, hex, a);
}
}
Expand All @@ -114,7 +114,7 @@ int cache_q(const char *clientid, const char *username, const char *topic, int a
char hex[SHA_DIGEST_LENGTH * 2 + 1];
struct aclcache *a;
struct userdata *ud = (struct userdata *)userdata;
time_t cachetics = ud->cachetics;
time_t cacheseconds = ud->cacheseconds;
int granted = MOSQ_ERR_UNKNOWN;

hexify(clientid, username, topic, access, hex);
Expand All @@ -125,7 +125,7 @@ int cache_q(const char *clientid, const char *username, const char *topic, int a

granted = a->granted;

if (time(NULL) > (a->tics + cachetics)) {
if (time(NULL) > (a->seconds + cacheseconds)) {
printf("EXPIRED!!!!!!!!!!!!!\n");
HASH_DEL(ud->aclcache, a);
}
Expand Down
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
struct aclcache {
char hex[SHA_DIGEST_LENGTH * 2 + 1]; /* key within struct */
int granted;
time_t tics;
time_t seconds;
UT_hash_handle hh;
};

Expand Down
2 changes: 1 addition & 1 deletion userdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct userdata {
int authentication_be; /* Back-end number user was authenticated in */
int fallback_be; /* Backend to use for anonymous connections */
char *anonusername; /* Configured name of anonymous MQTT user */
time_t cachetics; /* number of seconds to cache ACL lookups */
time_t cacheseconds; /* number of seconds to cache ACL lookups */
struct aclcache *aclcache;
};

Expand Down

0 comments on commit cad9e57

Please sign in to comment.