On Fri, 16 Sep 2011, Ruediger Pluem wrote:
On 09/15/2011 09:53 PM, [email protected] wrote:
Author: sf
Date: Thu Sep 15 19:53:59 2011
New Revision: 1171247

URL: http://svn.apache.org/viewvc?rev=1171247&view=rev
Log:
Create wrapper API for apr_random;
use in mod_lbmethod_heartbeat and mod_serf to
- replace some needles use of apr_generate_random_bytes
- remove code duplication

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/include/mod_core.h
    httpd/httpd/trunk/modules/http/http_core.c
    httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c
    httpd/httpd/trunk/modules/proxy/mod_serf.c
    httpd/httpd/trunk/server/core.c


Modified: httpd/httpd/trunk/server/core.c
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1171247&r1=1171246&r2=1171247&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Thu Sep 15 19:53:59 2011
@@ -20,6 +20,7 @@
 #include "apr_fnmatch.h"
 #include "apr_hash.h"
 #include "apr_thread_proc.h"    /* for RLIMIT stuff */
+#include "apr_random.h"

 #define APR_WANT_IOVEC
 #define APR_WANT_STRFUNC
@@ -4593,12 +4594,93 @@ AP_DECLARE(int) ap_state_query(int query
     }
 }

+static apr_random_t *rng = NULL;
+#if APR_HAS_THREADS
+static apr_thread_mutex_t *rng_mutex = NULL;
+
+static void create_rng_mutex(apr_pool_t *pchild, server_rec *s)
+{
+    int threaded_mpm;
+    if (ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm) != APR_SUCCESS)
+        return;
+    if (threaded_mpm)
+        apr_thread_mutex_create(&rng_mutex, APR_THREAD_MUTEX_DEFAULT, pchild);

Shouldn't we use ap_mutex API here to let the user configure the mutex method?

This is a thread mutex, ap_mutex is only for proc and global mutexes. I don't think it is necessary to be able to choose between the thread mutex types (nested, unnested, default).

Reply via email to