httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: httpd-2.0/server/mpm/worker fdqueue.c fdqueue.h worker.c
Date Tue, 18 Sep 2001 21:14:18 GMT
rbb         01/09/18 14:14:18

  Modified:    .        CHANGES
               server/mpm/worker fdqueue.c fdqueue.h worker.c
  Log:
  Cleanup the worker MPM.  We no longer re-use transaction
  pools.  This incurs less overhead than shuffling the pools
  around so that they can be re-used.  Remove one of the
  queue's condition variables.  We just redefined the API to
  state that you can't try to add more stuff than you allocated
  segments for.
  
  Submitted by:	  Aaron Bannert <aaron@clove.org>
  
  Revision  Changes    Path
  1.361     +9 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.360
  retrieving revision 1.361
  diff -u -r1.360 -r1.361
  --- CHANGES	2001/09/18 09:06:33	1.360
  +++ CHANGES	2001/09/18 21:14:16	1.361
  @@ -1,5 +1,14 @@
   Changes with Apache 2.0.26-dev
   
  +  *) Cleanup the worker MPM.  We no longer re-use transaction
  +     pools.  This incurs less overhead than shuffling the pools
  +     around so that they can be re-used.  Remove one of the
  +     queue's condition variables.  We just redefined the API to
  +     state that you can't try to add more stuff than you allocated
  +     segments for.  [Aaron Bannert <aaron@clove.org>]
  +
  +  *) Fix SSL VPATH builds [Cody Sherr <csherr@covalent.net>]
  +
     *) Fixed persistent connections when a request contains a body.
        [Greg Stein]
   
  
  
  
  1.6       +7 -9      httpd-2.0/server/mpm/worker/fdqueue.c
  
  Index: fdqueue.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/fdqueue.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- fdqueue.c	2001/08/27 23:50:12	1.5
  +++ fdqueue.c	2001/09/18 21:14:18	1.6
  @@ -89,7 +89,6 @@
        * XXX: We should at least try to signal an error here, it is
        * indicative of a programmer error. -aaron */
       pthread_cond_destroy(&queue->not_empty);
  -    pthread_cond_destroy(&queue->not_full);
       pthread_mutex_destroy(&queue->one_big_mutex);
   
       return FD_QUEUE_SUCCESS;
  @@ -107,8 +106,6 @@
           return FD_QUEUE_FAILURE;
       if (pthread_cond_init(&queue->not_empty, NULL) != 0)
           return FD_QUEUE_FAILURE;
  -    if (pthread_cond_init(&queue->not_full, NULL) != 0)
  -        return FD_QUEUE_FAILURE;
   
       bounds = queue_capacity + 1;
       queue->head = queue->tail = 0;
  @@ -136,9 +133,13 @@
           return FD_QUEUE_FAILURE;
       }
   
  -    /* Keep waiting until we wake up and find that the queue is not full. */
  -    while (ap_queue_full(queue)) {
  -        pthread_cond_wait(&queue->not_full, &queue->one_big_mutex);
  +    /* If the caller didn't allocate enough slots and tries to push
  +     * too many, too bad. */
  +    if (ap_queue_full(queue)) {
  +        if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
  +            return FD_QUEUE_FAILURE;
  +        }
  +        return FD_QUEUE_OVERFLOW;
       }
   
       queue->data[queue->tail].sd = sd;
  @@ -187,9 +188,6 @@
           queue->head = (queue->head + 1) % queue->bounds;
       }
       queue->blanks++;
  -
  -    /* we just consumed a slot, so we're no longer full */
  -    pthread_cond_signal(&queue->not_full);
   
       if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
           return FD_QUEUE_FAILURE;
  
  
  
  1.6       +1 -1      httpd-2.0/server/mpm/worker/fdqueue.h
  
  Index: fdqueue.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/fdqueue.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- fdqueue.h	2001/08/24 16:49:39	1.5
  +++ fdqueue.h	2001/09/18 21:14:18	1.6
  @@ -72,6 +72,7 @@
   #define FD_QUEUE_FAILURE -1 /* Needs to be an invalid file descriptor because
                                  of queue_pop semantics */
   #define FD_QUEUE_EINTR APR_EINTR
  +#define FD_QUEUE_OVERFLOW -2
   
   struct fd_queue_elem_t {
       apr_socket_t      *sd;
  @@ -87,7 +88,6 @@
       int                blanks;
       pthread_mutex_t    one_big_mutex;
       pthread_cond_t     not_empty;
  -    pthread_cond_t     not_full;
       int                cancel_state;
   };
   typedef struct fd_queue_t fd_queue_t;
  
  
  
  1.22      +6 -35     httpd-2.0/server/mpm/worker/worker.c
  
  Index: worker.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- worker.c	2001/08/30 20:50:06	1.21
  +++ worker.c	2001/09/18 21:14:18	1.22
  @@ -123,7 +123,6 @@
   static int num_listensocks = 0;
   static apr_socket_t **listensocks;
   static fd_queue_t *worker_queue;
  -static fd_queue_t *pool_queue; /* a resource pool of context pools */
   
   /* The structure used to pass unique initialization info to each thread */
   typedef struct {
  @@ -204,7 +203,6 @@
       /* XXX: This will happen naturally on a graceful, and we don't care otherwise.
       ap_queue_signal_all_wakeup(worker_queue); */
       ap_queue_interrupt_all(worker_queue);
  -    ap_queue_interrupt_all(pool_queue);
   }
   
   AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
  @@ -558,7 +556,6 @@
       int thread_slot = ti->tid;
       apr_pool_t *tpool = apr_thread_pool_get(thd);
       apr_socket_t *csd = NULL;
  -    apr_socket_t *dummycsd = NULL;
       apr_pool_t *ptrans;		/* Pool for per-transaction stuff */
       apr_socket_t *sd = NULL;
       int n;
  @@ -644,20 +641,9 @@
           }
       got_fd:
           if (!workers_may_exit) {
  +            /* create a new transaction pool for each accepted socket */
  +            apr_pool_create(&ptrans, tpool);
   
  -            /* pull the next available transaction pool from the queue */
  -            if ((rv = ap_queue_pop(pool_queue, &dummycsd, &ptrans))
  -                != FD_QUEUE_SUCCESS) {
  -                if (rv == FD_QUEUE_EINTR) {
  -                    goto got_fd;
  -                }
  -                else { /* got some error in the queue */
  -                    csd = NULL;
  -                    ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, 
  -                        "ap_queue_pop");
  -                }
  -            }
  -
               if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) {
                   csd = NULL;
                   ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, 
  @@ -692,7 +678,9 @@
       ap_scoreboard_image->parent[process_slot].quiescing = 1;
       kill(ap_my_pid, SIGTERM);
   
  +/* Unsure if this can be safely uncommented. -aaron
       apr_thread_exit(thd, APR_SUCCESS);
  +*/
       return NULL;
   }
   
  @@ -718,12 +706,7 @@
           }
           process_socket(ptrans, csd, process_slot, thread_slot);
           requests_this_child--; /* FIXME: should be synchronized - aaron */
  -
  -        /* get this transaction pool ready for the next request */
  -        apr_pool_clear(ptrans);
  -        /* don't bother checking if we were interrupted in ap_queue_push,
  -         * because we're going to check workers_may_exit right now anyway. */
  -        ap_queue_push(pool_queue, NULL, ptrans);
  +        apr_pool_destroy(ptrans);
       }
   
       ap_update_child_status(process_slot, thread_slot,
  @@ -758,23 +741,11 @@
       int i = 0;
       int threads_created = 0;
       apr_thread_t *listener;
  -    apr_pool_t *ptrans;
  -    apr_socket_t *dummycsd = NULL;
   
       /* We must create the fd queues before we start up the listener
        * and worker threads. */
  -    worker_queue = apr_pcalloc(pchild, sizeof(fd_queue_t));
  +    worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue));
       ap_queue_init(worker_queue, ap_threads_per_child, pchild);
  -
  -    /* create the resource pool of available transaction pools */
  -    pool_queue = apr_pcalloc(pchild, sizeof(fd_queue_t));
  -    ap_queue_init(pool_queue, ap_threads_per_child, pchild);
  -    /* fill the pool_queue with real pools */
  -    for (i = 0; i < ap_threads_per_child; i++) {
  -        ptrans = NULL;
  -        apr_pool_create(&ptrans, pchild);
  -        ap_queue_push(pool_queue, dummycsd, ptrans);
  -    }
   
       my_info = (proc_info *)malloc(sizeof(proc_info));
       my_info->pid = my_child_num;
  
  
  

Mime
View raw message