diff options
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/cache.c b/src/cache.c index 30c95516..ba2ca741 100644 --- a/src/cache.c +++ b/src/cache.c @@ -42,6 +42,9 @@ cache_get(char *email) DBM_DATUM contents; int readonly = 0; int res; + + if (!cache_format->enabled) + return mf_failure; debug1(50, "getting cache info for %s", email); if (mu_dbm_open(cache_format->dbname, &db, MU_STREAM_RDWR, 0600, @@ -101,6 +104,9 @@ cache_insert(char *email, mf_status rc) struct cache_result res; char timebuf[80]; + if (!cache_format->enabled) + return; + time(&res.timestamp); res.status = rc; debug4(50,"inserting cache info for %s. status=%s (%d), time=%s", @@ -149,7 +155,11 @@ mf_status cache_get2(char *email, char *client_addr) { mf_status rc = mf_failure; - size_t size = strlen(email) + 1 + strlen(client_addr) + 1; + size_t size; + + if (!cache_format->enabled) + return mf_failure; + size = strlen(email) + 1 + strlen(client_addr) + 1; char *key = malloc(size); if (key) { strcat(strcat(strcpy(key, email), ":"), client_addr); @@ -162,18 +172,23 @@ cache_get2(char *email, char *client_addr) void cache_insert2(char *email, char *client_addr, mf_status rc) { - size_t size = strlen(email) + 1 + strlen(client_addr) + 1; - char *key = malloc(size); - if (key) { - strcat(strcat(strcpy(key, email), ":"), client_addr); - cache_insert(key, rc); - free(key); + if (!cache_format->enabled) + return; + else { + size_t size = strlen(email) + 1 + strlen(client_addr) + 1; + char *key = malloc(size); + if (key) { + strcat(strcat(strcpy(key, email), ":"), client_addr); + cache_insert(key, rc); + free(key); + } } } static struct db_format cache_format_struct = { "cache", DEFAULT_DATABASE, + 1, DEFAULT_EXPIRE_INTERVAL, cache_print_item, cache_expire_item |