You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/02/16 23:08:13 UTC

cvs commit: httpd-2.0/server/mpm/threaded threaded.c

rbb         01/02/16 14:08:13

  Modified:    .        CHANGES
               server/mpm/threaded threaded.c
  Log:
  Make the threaded MPM use APR locks instead of pthreads mutexes.  This is
  the first step towards getting the threaded MPM to rely on APR for all of
  it's threading needs.
  
  Revision  Changes    Path
  1.96      +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -d -b -w -u -r1.95 -r1.96
  --- CHANGES	2001/02/16 18:59:48	1.95
  +++ CHANGES	2001/02/16 22:08:10	1.96
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.12-dev
   
  +  *) Move the threaded MPM to use APR locks instead of pthread locks.
  +     [Ryan Bloom]
  +
     *) Rename mpmt_pthread to threaded.  This is more in line with the
        fact that mpmt_pthread shouldn't be using pthreads directly, and
        it is a smaller name that doesn't tie into anything.
  
  
  
  1.2       +13 -11    httpd-2.0/server/mpm/threaded/threaded.c
  
  Index: threaded.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -d -b -w -u -r1.1 -r1.2
  --- threaded.c	2001/02/16 19:00:24	1.1
  +++ threaded.c	2001/02/16 22:08:12	1.2
  @@ -92,8 +92,8 @@
   #include <netinet/tcp.h>
   #endif
   
  -#include <pthread.h>
   #include <signal.h>
  +#include <pthread.h>
   
   /*
    * Actual definitions of config globals
  @@ -130,7 +130,7 @@
   
   static apr_file_t *pipe_of_death_in = NULL;
   static apr_file_t *pipe_of_death_out = NULL;
  -static pthread_mutex_t pipe_of_death_mutex;
  +static apr_lock_t *pipe_of_death_mutex;
   
   /* *Non*-shared http_main globals... */
   
  @@ -160,7 +160,7 @@
                              thread. Use this instead */
   /* Keep track of the number of worker threads currently active */
   static int worker_thread_count;
  -static pthread_mutex_t worker_thread_count_mutex;
  +static apr_lock_t *worker_thread_count_mutex;
   
   /* Locks for accept serialization */
   static apr_lock_t *accept_mutex;
  @@ -423,7 +423,7 @@
   /* Sets workers_may_exit if we received a character on the pipe_of_death */
   static void check_pipe_of_death(void)
   {
  -    pthread_mutex_lock(&pipe_of_death_mutex);
  +    apr_lock_acquire(pipe_of_death_mutex);
       if (!workers_may_exit) {
           apr_status_t ret;
           char pipe_read_char;
  @@ -440,7 +440,7 @@
               workers_may_exit = 1;
           }
       }
  -    pthread_mutex_unlock(&pipe_of_death_mutex);
  +    apr_lock_release(pipe_of_death_mutex);
   }
   
   static void * worker_thread(void * dummy)
  @@ -461,9 +461,9 @@
   
       apr_pool_create(&ptrans, tpool);
   
  -    pthread_mutex_lock(&worker_thread_count_mutex);
  +    apr_lock_acquire(worker_thread_count_mutex);
       worker_thread_count++;
  -    pthread_mutex_unlock(&worker_thread_count_mutex);
  +    apr_lock_release(worker_thread_count_mutex);
   
       apr_poll_setup(&pollset, num_listensocks+1, tpool);
       for(n=0 ; n <= num_listensocks ; ++n)
  @@ -569,14 +569,14 @@
       apr_pool_destroy(tpool);
       ap_update_child_status(process_slot, thread_slot, SERVER_DEAD,
           (request_rec *) NULL);
  -    pthread_mutex_lock(&worker_thread_count_mutex);
  +    apr_lock_acquire(worker_thread_count_mutex);
       worker_thread_count--;
       if (worker_thread_count == 0) {
           /* All the threads have exited, now finish the shutdown process
            * by signalling the sigwait thread */
           kill(ap_my_pid, SIGTERM);
       }
  -    pthread_mutex_unlock(&worker_thread_count_mutex);
  +    apr_lock_release(worker_thread_count_mutex);
   
       return NULL;
   }
  @@ -647,8 +647,10 @@
       /* Setup worker threads */
   
       worker_thread_count = 0;
  -    pthread_mutex_init(&worker_thread_count_mutex, NULL);
  -    pthread_mutex_init(&pipe_of_death_mutex, NULL);
  +    apr_lock_create(&worker_thread_count_mutex, APR_MUTEX, APR_INTRAPROCESS,
  +                    NULL, pchild);
  +    apr_lock_create(&pipe_of_death_mutex, APR_MUTEX, APR_INTRAPROCESS, 
  +                    NULL, pchild);
       pthread_attr_init(&thread_attr);
   #ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR
       {