summaryrefslogtreecommitdiff
path: root/modules/ldap
diff options
context:
space:
mode:
authorStefan Fritsch <sf@sfritsch.de>2011-12-27 19:42:53 +0100
committerStefan Fritsch <sf@sfritsch.de>2011-12-27 19:42:53 +0100
commitdb26b587c04799e75b6dd0fcd4b46aaa168f9161 (patch)
tree127af2f77fd3eddb75604ebecedeeea163325078 /modules/ldap
parentd9f98b967bedecc0bffe82682d1ed4e06c9df687 (diff)
downloadapache2-db26b587c04799e75b6dd0fcd4b46aaa168f9161.tar.gz
Upstream tarball 2.2.15upstream/2.2.15
Diffstat (limited to 'modules/ldap')
-rw-r--r--modules/ldap/util_ldap.c2
-rw-r--r--modules/ldap/util_ldap_cache_mgr.c62
2 files changed, 56 insertions, 8 deletions
diff --git a/modules/ldap/util_ldap.c b/modules/ldap/util_ldap.c
index 5b432696..a894b6ea 100644
--- a/modules/ldap/util_ldap.c
+++ b/modules/ldap/util_ldap.c
@@ -1820,7 +1820,7 @@ static void *util_ldap_create_config(apr_pool_t *p, server_rec *s)
apr_thread_mutex_create(&st->mutex, APR_THREAD_MUTEX_DEFAULT, st->pool);
#endif
- st->cache_bytes = 100000;
+ st->cache_bytes = 500000;
st->search_cache_ttl = 600000000;
st->search_cache_size = 1024;
st->compare_cache_ttl = 600000000;
diff --git a/modules/ldap/util_ldap_cache_mgr.c b/modules/ldap/util_ldap_cache_mgr.c
index 56b8cbec..6bb066ab 100644
--- a/modules/ldap/util_ldap_cache_mgr.c
+++ b/modules/ldap/util_ldap_cache_mgr.c
@@ -385,6 +385,7 @@ void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload)
void *util_ald_cache_insert(util_ald_cache_t *cache, void *payload)
{
unsigned long hashval;
+ void *tmp_payload;
util_cache_node_t *node;
/* sanity check */
@@ -397,21 +398,68 @@ void *util_ald_cache_insert(util_ald_cache_t *cache, void *payload)
util_ald_cache_purge(cache);
if (cache->numentries >= cache->maxentries) {
/* if the purge was not effective, we leave now to avoid an overflow */
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "Purge of LDAP cache failed");
return NULL;
}
}
- /* should be safe to add an entry */
- if ((node = (util_cache_node_t *)util_ald_alloc(cache, sizeof(util_cache_node_t))) == NULL) {
- return NULL;
+ node = (util_cache_node_t *)util_ald_alloc(cache,
+ sizeof(util_cache_node_t));
+ if (node == NULL) {
+ /*
+ * XXX: The cache management should be rewritten to work
+ * properly when LDAPSharedCacheSize is too small.
+ */
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
+ "LDAPSharedCacheSize is too small. Increase it or "
+ "reduce LDAPCacheEntries/LDAPOpCacheEntries!");
+ if (cache->numentries < cache->fullmark) {
+ /*
+ * We have not even reached fullmark, trigger a complete purge.
+ * This is still better than not being able to add new entries
+ * at all.
+ */
+ cache->marktime = apr_time_now();
+ }
+ util_ald_cache_purge(cache);
+ node = (util_cache_node_t *)util_ald_alloc(cache,
+ sizeof(util_cache_node_t));
+ if (node == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "Could not allocate memory for LDAP cache entry");
+ return NULL;
+ }
}
/* Take a copy of the payload before proceeeding. */
- payload = (*cache->copy)(cache, payload);
- if (!payload) {
- util_ald_free(cache, node);
- return NULL;
+ tmp_payload = (*cache->copy)(cache, payload);
+ if (tmp_payload == NULL) {
+ /*
+ * XXX: The cache management should be rewritten to work
+ * properly when LDAPSharedCacheSize is too small.
+ */
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
+ "LDAPSharedCacheSize is too small. Increase it or "
+ "reduce LDAPCacheEntries/LDAPOpCacheEntries!");
+ if (cache->numentries < cache->fullmark) {
+ /*
+ * We have not even reached fullmark, trigger a complete purge.
+ * This is still better than not being able to add new entries
+ * at all.
+ */
+ cache->marktime = apr_time_now();
+ }
+ util_ald_cache_purge(cache);
+ tmp_payload = (*cache->copy)(cache, payload);
+ if (tmp_payload == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "Could not allocate memory for LDAP cache value");
+ util_ald_free(cache, node);
+ return NULL;
+ }
}
+ payload = tmp_payload;
/* populate the entry */
cache->inserts++;