]> granicus.if.org Git - apache/commitdiff
Thread saftey lock for mod_rewrite's cache... I'm sure others will have
authorWilliam A. Rowe Jr <wrowe@apache.org>
Sun, 21 Oct 2001 01:24:35 +0000 (01:24 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Sun, 21 Oct 2001 01:24:35 +0000 (01:24 +0000)
  some 'better ideas' but this will work for now.

Submitted by: Brian Pane <bpane@pacbell.net>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91612 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c
modules/mappers/mod_rewrite.h

diff --git a/CHANGES b/CHANGES
index e833898512a1150c571da95d63d404dd9099fdc4..a942ac295ab0dac642ee73497af2812e9e87a875 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
 Changes with Apache 2.0.27-dev
 
+  *) Introduced thread saftey for mod_rewrite's internal cache.
+     [Brian Pane <bpane@pacbell.net>]
+
+  *) Simplified mod_env's directives to behave as most directives are
+     expected, in that UnsetEnv will not unset a SetEnv and PassEnv 
+     directive following that UnsetEnv within the same container.
+     Also provides a runtime startup warning if a PassEnv configured 
+     environment value is undefined.  [William Rowe]
+
   *) The worker MPM is now completely ported to APR's new lock API. It
      uses native APR types for thread mutexes, cross-process mutexes,
      and condition variables.  [Aaron Bannert]
index 1fa5108518fa6776544a59351f92c1a6767ba72b..b37fdf0fb3f4bb826c414cfbd3d9f37818c172b2 100644 (file)
@@ -3665,6 +3665,9 @@ static cache *init_cache(apr_pool_t *p)
     if (apr_pool_create(&c->pool, p) != APR_SUCCESS)
                return NULL;
     c->lists = apr_array_make(c->pool, 2, sizeof(cachelist));
+#if APR_HAS_THREADS
+    (void)apr_lock_create(&(c->lock), APR_MUTEX, APR_INTRAPROCESS, NULL, p);
+#endif
     return c;
 }
 
@@ -3755,6 +3758,10 @@ static void store_cache_string(cache *c, const char *res, cacheentry *ce)
     cachetlbentry *t;
     int found_list;
 
+#if APR_HAS_THREADS
+    apr_lock_acquire(c->lock);
+#endif
+
     found_list = 0;
     /* first try to edit an existing entry */
     for (i = 0; i < c->lists->nelts; i++) {
@@ -3767,6 +3774,9 @@ static void store_cache_string(cache *c, const char *res, cacheentry *ce)
             if (e != NULL) {
                 e->time  = ce->time;
                 e->value = apr_pstrdup(c->pool, ce->value);
+#if APR_HAS_THREADS
+                apr_lock_release(c->lock);
+#endif
                 return;
             }
 
@@ -3775,8 +3785,11 @@ static void store_cache_string(cache *c, const char *res, cacheentry *ce)
                 if (strcmp(e->key, ce->key) == 0) {
                     e->time  = ce->time;
                     e->value = apr_pstrdup(c->pool, ce->value);
-                  cache_tlb_replace((cachetlbentry *)l->tlb->elts,
-                                    (cacheentry *)l->entries->elts, e);
+                    cache_tlb_replace((cachetlbentry *)l->tlb->elts,
+                                      (cacheentry *)l->entries->elts, e);
+#if APR_HAS_THREADS
+                    apr_lock_release(c->lock);
+#endif
                     return;
                 }
             }
@@ -3807,11 +3820,17 @@ static void store_cache_string(cache *c, const char *res, cacheentry *ce)
             e->value = apr_pstrdup(c->pool, ce->value);
             cache_tlb_replace((cachetlbentry *)l->tlb->elts,
                               (cacheentry *)l->entries->elts, e);
+#if APR_HAS_THREADS
+            apr_lock_release(c->lock);
+#endif
             return;
         }
     }
 
     /* not reached, but when it is no problem... */
+#if APR_HAS_THREADS
+    apr_lock_release(c->lock);
+#endif
     return;
 }
 
@@ -3822,23 +3841,37 @@ static cacheentry *retrieve_cache_string(cache *c, const char *res, char *key)
     cachelist *l;
     cacheentry *e;
 
+#if APR_HAS_THREADS
+    apr_lock_acquire(c->lock);
+#endif
+
     for (i = 0; i < c->lists->nelts; i++) {
         l = &(((cachelist *)c->lists->elts)[i]);
         if (strcmp(l->resource, res) == 0) {
 
             e = cache_tlb_lookup((cachetlbentry *)l->tlb->elts,
                                  (cacheentry *)l->entries->elts, key);
-            if (e != NULL)
+            if (e != NULL) {
+#if APR_HAS_THREADS
+                apr_lock_release(c->lock);
+#endif
                 return e;
+            }
 
             for (j = 0; j < l->entries->nelts; j++) {
                 e = &(((cacheentry *)l->entries->elts)[j]);
                 if (strcmp(e->key, key) == 0) {
+#if APR_HAS_THREADS
+                    apr_lock_release(c->lock);
+#endif
                     return e;
                 }
             }
         }
     }
+#if APR_HAS_THREADS
+    apr_lock_release(c->lock);
+#endif
     return NULL;
 }
 
index 4458575c6e7672caa71bc1b2afa132f31d612a25..56a85a18016e92f34d4640eb68e25fab0c8a78a7 100644 (file)
 #include <sys/types.h>
 #endif
 
+#if APR_HAS_THREADS
+#include "apr_lock.h"
+#endif
 #include "ap_config.h"
 
     /* Include from the Apache server ... */
@@ -322,6 +325,9 @@ typedef struct cachelist {
 typedef struct cache {
     apr_pool_t         *pool;
     apr_array_header_t *lists;
+#if APR_HAS_THREADS
+    apr_lock_t *lock;
+#endif
 } cache;