httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Bannert <aa...@clove.org>
Subject [PATCH] change mod_rewrite to use apr_global_mutex_t
Date Mon, 18 Feb 2002 01:32:41 GMT
On Sun, Feb 17, 2002 at 02:51:43PM -0800, Brian Pane wrote:
> You're right; the apr_proc_mutex_t won't be sufficient in this
> case.  We'll really need apr_global_mutex_t for this.  If that's
> going to be available soon, I'll switch the rewrite code to use
> it when it's released; but if not, I'll revert to the old lock
> API for now.
> --Brian

I've committed the new API for Unix, but will not make the conversion
to the new API until the other platforms are up to speed. In the
mean time, here is a patch to convert to the new API for mod_rewrite.
I've tested it as well as I can, but I could use some help exercising
the new lock code in a massively concurrent environment:

-aaron


Index: modules/mappers/mod_rewrite.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
retrieving revision 1.96
diff -u -r1.96 mod_rewrite.c
--- modules/mappers/mod_rewrite.c	16 Feb 2002 21:57:17 -0000	1.96
+++ modules/mappers/mod_rewrite.c	18 Feb 2002 01:29:07 -0000
@@ -93,6 +93,7 @@
 #include "apr_user.h"
 #include "apr_lib.h"
 #include "apr_signal.h"
+#include "apr_global_mutex.h"
 #include "apr_proc_mutex.h"
 
 #define APR_WANT_STRFUNC
@@ -188,7 +189,7 @@
 
 static const char *lockname;
 static apr_proc_mutex_t *rewrite_mapr_lock_acquire = NULL;
-static apr_lock_t *rewrite_log_lock = NULL;
+static apr_global_mutex_t *rewrite_log_lock = NULL;
 
 /*
 ** +-------------------------------------------------------+
@@ -942,8 +943,8 @@
     proxy_available = (ap_find_linked_module("mod_proxy.c") != NULL);
 
     /* create the rewriting lockfiles in the parent */
-    if ((rv = apr_lock_create(&rewrite_log_lock, APR_MUTEX, APR_LOCKALL,
-                              APR_LOCK_DEFAULT, NULL, p)) != APR_SUCCESS) {
+    rv = apr_global_mutex_create(&rewrite_log_lock, NULL, APR_LOCK_DEFAULT, p);
+    if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
                      "mod_rewrite: could not create rewrite_log_lock");
         return HTTP_INTERNAL_SERVER_ERROR;
@@ -3218,10 +3219,10 @@
                 (unsigned long)(r->server), (unsigned long)r,
                 type, redir, level, str2);
 
-    apr_lock_acquire(rewrite_log_lock);
+    apr_global_mutex_lock(rewrite_log_lock);
     nbytes = strlen(str3);
     apr_file_write(conf->rewritelogfp, str3, &nbytes);
-    apr_lock_release(rewrite_log_lock);
+    apr_global_mutex_unlock(rewrite_log_lock);
 
     va_end(ap);
     return;

Mime
View raw message