httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Bannert <aa...@clove.org>
Subject [PATCH] convert BeOS MPM to use new lock API
Date Wed, 27 Feb 2002 02:54:50 GMT
I don't have BeOS so I can't verify this patch. Should be simple
enough to verify.

-aaron


Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.85
diff -u -u -r1.85 beos.c
--- server/mpm/beos/beos.c	21 Feb 2002 18:52:28 -0000	1.85
+++ server/mpm/beos/beos.c	27 Feb 2002 02:52:46 -0000
@@ -68,6 +68,7 @@
  
 #include "apr_strings.h"
 #include "apr_portable.h"
+#include "apr_proc_mutex.h"
 #include "httpd.h" 
 #include "http_main.h" 
 #include "http_log.h" 
@@ -129,7 +130,7 @@
 static int ap_thread_limit=0;
 static int num_listening_sockets = 0;
 static apr_socket_t ** listening_sockets;
-apr_lock_t *accept_mutex = NULL;
+apr_proc_mutex_t *accept_mutex = NULL;
 
 static apr_pool_t *pconf;		/* Pool for config stuff */
 static apr_pool_t *pchild;		/* Pool for httpd child stuff */
@@ -138,7 +139,7 @@
 
 /* Keep track of the number of worker threads currently active */
 static int worker_thread_count;
-apr_lock_t *worker_thread_count_mutex;
+apr_proc_mutex_t *worker_thread_count_mutex;
 
 /* The structure used to pass unique initialization info to each thread */
 typedef struct {
@@ -381,9 +382,9 @@
     apr_pool_create_ex(&ptrans, tpool, NULL, APR_POOL_FNEW_ALLOCATOR);
     apr_pool_tag(ptrans, "transaction");
 
-    apr_lock_acquire(worker_thread_count_mutex);
+    apr_proc_mutex_lock(worker_thread_count_mutex);
     worker_thread_count++;
-    apr_lock_release(worker_thread_count_mutex);
+    apr_proc_mutex_unlock(worker_thread_count_mutex);
 
     (void) ap_update_child_status_from_indexes(0, child_slot, SERVER_STARTING,
                                                (request_rec*)NULL);
@@ -405,7 +406,7 @@
         (void) ap_update_child_status_from_indexes(0, child_slot, SERVER_READY,
                                                    (request_rec*)NULL);
 
-        apr_lock_acquire(accept_mutex);
+        apr_proc_mutex_lock(accept_mutex);
 
         while (!this_worker_should_exit) {
             apr_int16_t event;
@@ -474,7 +475,7 @@
         if (!this_worker_should_exit) {
             rv = apr_accept(&csd, sd, ptrans);
 
-            apr_lock_release(accept_mutex);
+            apr_proc_mutex_unlock(accept_mutex);
             if (rv != APR_SUCCESS) {
                 ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
                   "apr_accept");
@@ -484,7 +485,7 @@
             }
         }
         else {
-            apr_lock_release(accept_mutex);
+            apr_proc_mutex_unlock(accept_mutex);
             break;
         }
         apr_pool_clear(ptrans);
@@ -495,9 +496,9 @@
 ap_log_error(APLOG_MARK, APLOG_NOTICE | APLOG_NOERRNO, 0, NULL,
              "worker_thread %ld exiting", find_thread(NULL));
     
-    apr_lock_acquire(worker_thread_count_mutex);
+    apr_proc_mutex_lock(worker_thread_count_mutex);
     worker_thread_count--;
-    apr_lock_release(worker_thread_count_mutex);
+    apr_proc_mutex_unlock(worker_thread_count_mutex);
 
     return (0);
 }
@@ -810,8 +811,8 @@
      * used to lock around select so we only have one thread
      * in select at a time
      */
-    if ((rv = apr_lock_create(&accept_mutex, APR_MUTEX, APR_CROSS_PROCESS,
-                              APR_LOCK_DEFAULT, NULL, pconf)) != APR_SUCCESS) {
+    rv = apr_proc_mutex_create(&accept_mutex, NULL, APR_LOCK_DEFAULT, pconf);
+    if (rv != APR_SUCCESS) {
         /* tsch tsch, can't have more than one thread in the accept loop
            at a time so we need to fall on our sword... */
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
@@ -822,8 +823,9 @@
     /* worker_thread_count_mutex
      * locks the worker_thread_count so we have ana ccurate count...
      */
-    if ((rv = apr_lock_create(&worker_thread_count_mutex, APR_MUTEX, APR_CROSS_PROCESS,
-                              APR_LOCK_DEFAULT, NULL, pconf)) != APR_SUCCESS) {
+    rv = apr_proc_mutex_create(&worker_thread_count_mutex, NULL,
+                               APR_LOCK_DEFAULT, pconf);
+    if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                      "Couldn't create worker thread count lock");
         return 1;
@@ -984,8 +986,8 @@
     
     /* just before we go, tidy up the locks we've created to prevent a 
      * potential leak of semaphores... */
-    apr_lock_destroy(worker_thread_count_mutex);
-    apr_lock_destroy(accept_mutex);
+    apr_proc_mutex_destroy(worker_thread_count_mutex);
+    apr_proc_mutex_destroy(accept_mutex);
     
     return 0;
 }

Mime
View raw message