httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)" <madhusudan_mathiha...@hp.com>
Subject [PATCH] Use mutex locks in mod_specweb99.c
Date Wed, 11 Dec 2002 05:40:09 GMT
I started seeing the following errors in the specweb99 run output, when I
use mod_specweb99.c with Apache 2.0.43 and worker MPM. The following patch
seems to get rid of the problem. If you're thinking that it may degrade the
response - I did not find much difference though. 

Can somebody please evaluate and let me know if it's okay ?.

----------------------------------------------------------------
ERRORS FOUND
Iteration 3: out of order entry in log

     Errorseen: 0, lastseen= 3694

     Count: 3694, num= 6

Iteration 3: Number of POST requests in log inconsistant

     Reference_count = 238213, real_count = 239179

-----------------------------------------------------------------

Thanks
-Madhu

Index: mod_specweb99.c
===================================================================
RCS file:
/home/cvspublic/httpd-test/specweb99/specweb99-2.0/mod_specweb99.c,v
retrieving revision 1.16
diff -u -r1.16 mod_specweb99.c
--- mod_specweb99.c     31 Oct 2002 19:39:04 -0000      1.16
+++ mod_specweb99.c     11 Dec 2002 05:30:12 -0000
@@ -83,6 +83,10 @@
 #include <unistd.h>
 #endif

+#if APR_HAS_THREADS
+apr_thread_mutex_t *log_mutex;
+#endif
+
 /* Note: version must be of the x.yy type - as it is
  * send over the http protocol wire; where x and y
  * are single 0-9 ascii digits :-). The name should
@@ -600,6 +604,10 @@
     if (apr_pool_create(&(_my->cad_pool), p) != APR_SUCCESS)
        exit(APEXIT_CHILDFATAL);

+#if APR_HAS_THREADS
+    apr_thread_mutex_create(&log_mutex, APR_THREAD_MUTEX_DEFAULT, p);
+#endif
+
     if (s->next) {
        fprintf(stderr,
                "WARNING- this specweb module currently does not support
vhosts/services\n"
@@ -1175,8 +1183,15 @@
        return HTTP_INTERNAL_SERVER_ERROR;
     }

-    if ((rv = _wlock(r->server, r, f, _my->log_path)) != APR_SUCCESS)
+#if APR_HAS_THREADS
+    apr_thread_mutex_lock(log_mutex);
+#endif
+    if ((rv = _wlock(r->server, r, f, _my->log_path)) != APR_SUCCESS) {
+#if APR_HAS_THREADS
+        apr_thread_mutex_unlock(log_mutex);
+#endif
        returnHTMLPageWithMessage(r, "Failed to lock post.log file");
+    }
     else {
        char *msg =
        _log_and_write(r, f, filename, urlroot, dirnum, classnum, filenum,
@@ -1184,6 +1199,9 @@
        if (msg) {
            rv = APR_OS_START_USEERR;
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, msg);
+#if APR_HAS_THREADS
+            apr_thread_mutex_unlock(log_mutex);
+#endif
            returnHTMLPageWithMessage(r, msg);
        }
     }
@@ -1193,10 +1211,16 @@
            rv = rv2;
            ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
                         "Failed to unlock %s", filename ? filename : "");
+#if APR_HAS_THREADS
+            apr_thread_mutex_unlock(log_mutex);
+#endif
            returnHTMLPageWithMessage(r, "Failed to lock unpost.log file");
        }
     }

+#if APR_HAS_THREADS
+    apr_thread_mutex_unlock(log_mutex);
+#endif
     apr_file_close(f);

     if (rv != APR_SUCCESS)

Mime
View raw message