httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1096577 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_ldap.xml modules/ldap/util_ldap.c modules/ldap/util_ldap_cache.c modules/ldap/util_ldap_cache_mgr.c
Date Mon, 25 Apr 2011 20:00:44 GMT
Author: sf
Date: Mon Apr 25 20:00:43 2011
New Revision: 1096577

URL: http://svn.apache.org/viewvc?rev=1096577&view=rev
Log:
mod_ldap: Make LDAPSharedCacheSize 0 create a non-shared-memory cache per
process as opposed to disabling caching completely. This allows to use
the non-shared-memory cache as a workaround for the shared memory cache
not being available during graceful restarts

PR: 48958

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mod_ldap.xml
    httpd/httpd/trunk/modules/ldap/util_ldap.c
    httpd/httpd/trunk/modules/ldap/util_ldap_cache.c
    httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1096577&r1=1096576&r2=1096577&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Apr 25 20:00:43 2011
@@ -2,6 +2,11 @@
 
 Changes with Apache 2.3.12
 
+  *) mod_ldap: Make LDAPSharedCacheSize 0 create a non-shared-memory cache per
+     process as opposed to disabling caching completely. This allows to use
+     the non-shared-memory cache as a workaround for the shared memory cache
+     not being available during graceful restarts. PR 48958. [Stefan Fritsch]
+
   *) Add new ap_reserve_module_slots/ap_reserve_module_slots_directive API,
      necessary if a module (like mod_perl) registers additional modules late
      in the startup phase. [Stefan Fritsch]

Modified: httpd/httpd/trunk/docs/manual/mod/mod_ldap.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_ldap.xml?rev=1096577&r1=1096576&r2=1096577&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_ldap.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_ldap.xml Mon Apr 25 20:00:43 2011
@@ -423,7 +423,8 @@ by other LDAP modules</description>
 <usage>
     <p>Specifies the number of bytes to allocate for the shared
     memory cache. The default is 500kb. If set to 0, shared memory
-    caching will not be used.</p>
+    caching will not be used and every HTTPD process will create its
+    own cache.</p>
 </usage>
 </directivesynopsis>
 

Modified: httpd/httpd/trunk/modules/ldap/util_ldap.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap.c?rev=1096577&r1=1096576&r2=1096577&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap.c Mon Apr 25 20:00:43 2011
@@ -2728,9 +2728,12 @@ static int util_ldap_post_config(apr_poo
     if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
 
 #if APR_HAS_SHARED_MEMORY
-        /* If the cache file already exists then delete it.  Otherwise we are
-         * going to run into problems creating the shared memory. */
-        if (st->cache_file) {
+        /*
+         * If we are using shared memory caching and the cache file already
+         * exists then delete it.  Otherwise we are going to run into problems
+         * creating the shared memory.
+         */
+        if (st->cache_file && st->cache_bytes > 0) {
             char *lck_file = apr_pstrcat(ptemp, st->cache_file, ".lck",
                                          NULL);
             apr_file_remove(lck_file, ptemp);
@@ -2740,10 +2743,10 @@ static int util_ldap_post_config(apr_poo
     }
 
 #if APR_HAS_SHARED_MEMORY
-    /* initializing cache if shared memory size is not zero and we already
-     * don't have shm address
+    /*
+     * initializing cache if we don't already have a shm address
      */
-    if (!st->cache_shm && st->cache_bytes > 0) {
+    if (!st->cache_shm) {
 #endif
         result = util_ldap_cache_init(p, st);
         if (result != APR_SUCCESS) {
@@ -2865,7 +2868,7 @@ static const command_rec util_ldap_cmds[
     AP_INIT_TAKE1("LDAPSharedCacheSize", util_ldap_set_cache_bytes,
                   NULL, RSRC_CONF,
                   "Set the size of the shared memory cache (in bytes). Use "
-                  "0 to disable the shared memory cache. (default: 100000)"),
+                  "0 to disable the shared memory cache. (default: 500000)"),
 
     AP_INIT_TAKE1("LDAPSharedCacheFile", util_ldap_set_cache_file,
                   NULL, RSRC_CONF,

Modified: httpd/httpd/trunk/modules/ldap/util_ldap_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap_cache.c?rev=1096577&r1=1096576&r2=1096577&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap_cache.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap_cache.c Mon Apr 25 20:00:43 2011
@@ -420,27 +420,29 @@ apr_status_t util_ldap_cache_init(apr_po
     apr_status_t result;
     apr_size_t size;
 
-    if (st->cache_file) {
-        /* Remove any existing shm segment with this name. */
-        apr_shm_remove(st->cache_file, st->pool);
-    }
-
-    size = APR_ALIGN_DEFAULT(st->cache_bytes);
-
-    result = apr_shm_create(&st->cache_shm, size, st->cache_file, st->pool);
-    if (result != APR_SUCCESS) {
-        return result;
-    }
-
-    /* Determine the usable size of the shm segment. */
-    size = apr_shm_size_get(st->cache_shm);
-
-    /* This will create a rmm "handler" to get into the shared memory area */
-    result = apr_rmm_init(&st->cache_rmm, NULL,
-                          apr_shm_baseaddr_get(st->cache_shm), size,
-                          st->pool);
-    if (result != APR_SUCCESS) {
-        return result;
+    if (st->cache_bytes > 0) {
+        if (st->cache_file) {
+            /* Remove any existing shm segment with this name. */
+            apr_shm_remove(st->cache_file, st->pool);
+        }
+
+        size = APR_ALIGN_DEFAULT(st->cache_bytes);
+
+        result = apr_shm_create(&st->cache_shm, size, st->cache_file, st->pool);
+        if (result != APR_SUCCESS) {
+            return result;
+        }
+
+        /* Determine the usable size of the shm segment. */
+        size = apr_shm_size_get(st->cache_shm);
+
+        /* This will create a rmm "handler" to get into the shared memory area */
+        result = apr_rmm_init(&st->cache_rmm, NULL,
+                              apr_shm_baseaddr_get(st->cache_shm), size,
+                              st->pool);
+        if (result != APR_SUCCESS) {
+            return result;
+        }
     }
 
 #endif

Modified: httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c?rev=1096577&r1=1096576&r2=1096577&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap_cache_mgr.c Mon Apr 25 20:00:43 2011
@@ -331,16 +331,19 @@ util_ald_cache_t *util_ald_create_cache(
 {
     util_ald_cache_t *cache;
     unsigned long i;
+#if APR_HAS_SHARED_MEMORY
+    apr_rmm_off_t block;
+#endif
 
     if (cache_size <= 0)
         return NULL;
 
 #if APR_HAS_SHARED_MEMORY
     if (!st->cache_rmm) {
-        return NULL;
+        cache = (util_ald_cache_t *)calloc(sizeof(util_ald_cache_t), 1);
     }
     else {
-        apr_rmm_off_t block = apr_rmm_calloc(st->cache_rmm, sizeof(util_ald_cache_t));
+        block = apr_rmm_calloc(st->cache_rmm, sizeof(util_ald_cache_t));
         cache = block ? (util_ald_cache_t *)apr_rmm_addr_get(st->cache_rmm, block) : NULL;
     }
 #else
@@ -363,6 +366,14 @@ util_ald_cache_t *util_ald_create_cache(
     cache->nodes = (util_cache_node_t **)util_ald_alloc(cache, cache->size * sizeof(util_cache_node_t
*));
     if (!cache->nodes) {
         util_ald_free(cache, cache);
+#if APR_HAS_SHARED_MEMORY
+        if (!st->cache_rmm)
+            free(cache);
+        else
+            apr_rmm_free(st->cache_rmm, block);
+#else
+        free(cache);
+#endif
         return NULL;
     }
 



Mime
View raw message