auth-cache.c revision 1e50a4f930a028ab5fcf690503bfd13b54ff6787
/* Copyright (c) 2004-2010 Dovecot authors, see the included COPYING file */
#include "auth-common.h"
#include "lib-signals.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "var-expand.h"
#include "auth-request.h"
#include "auth-cache.h"
#include <time.h>
struct auth_cache {
struct hash_table *hash;
unsigned int ttl_secs, neg_ttl_secs;
unsigned int hit_count, miss_count;
unsigned int pos_entries, neg_entries;
};
{
char key_seen[256];
query++;
/* @UNSAFE */
}
}
}
return str_free_without_data(&str);
}
static void
{
else {
/* unlinking tail */
}
else {
/* unlinking head */
}
}
static void
struct auth_cache_node *node)
{
else
}
static void
{
}
{
i_info("SIGHUP received, clearing cache");
}
{
unsigned int total_count;
i_info("Authentication cache hits %u/%u (%u%%)",
i_info("Authentication cache inserts: "
"positive: %u %lluB, negative: %u %lluB",
/* reset counters */
}
unsigned int neg_ttl_secs
)
{
struct auth_cache *cache;
return cache;
}
{
}
{
}
const char *
bool *expired_r, bool *neg_expired_r)
{
struct auth_cache_node *node;
const char *value;
unsigned int ttl_secs;
*neg_expired_r = FALSE;
/* %! is prepended automatically. it contains the passdb ID number. */
cache->miss_count++;
return NULL;
}
/* TTL expired */
} else {
/* move to head */
}
}
*neg_expired_r = TRUE;
return value;
}
{
struct auth_cache_node *node;
char *current_username;
/* we're not caching negative entries */
return;
}
/* store into cache using the translated username, except if we're doing
a master user login */
/* %! is prepended automatically. it contains the db ID number. */
alloc_size = sizeof(struct auth_cache_node) -
/* make sure we have enough space */
/* key is already in cache (probably expired), remove it */
}
/* @UNSAFE */
if (*value != '\0') {
cache->pos_entries++;
} else {
cache->neg_entries++;
}
}
const struct auth_request *request,
const char *key)
{
struct auth_cache_node *node;
return;
}