You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by aa...@apache.org on 2002/04/26 19:13:51 UTC

cvs commit: httpd-2.0/server/mpm/worker fdqueue.c fdqueue.h

aaron       02/04/26 10:13:51

  Modified:    server/mpm/worker fdqueue.c fdqueue.h
  Log:
  Convert the worker MPM's fdqueue from a LIFO back into a FIFO. Since
  elements in the queue represent accept()ed connections, we want them
  to be processed in the order that they were received.  (I erroneously
  converted it to a LIFO quite awhile ago in the hopes that it would
  improve cache efficiency.)
  
  Remember to perform a make clean in the worker directory after this patch,
  since this patch changes the size of the fd_queue_t object (which is
  allocated in worker.c).
  
  Revision  Changes    Path
  1.15      +12 -7     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- fdqueue.c	21 Mar 2002 19:12:54 -0000	1.14
  +++ fdqueue.c	26 Apr 2002 17:13:51 -0000	1.15
  @@ -62,13 +62,13 @@
    * Detects when the fd_queue_t is full. This utility function is expected
    * to be called from within critical sections, and is not threadsafe.
    */
  -#define ap_queue_full(queue) ((queue)->tail == (queue)->bounds)
  +#define ap_queue_full(queue) ((queue)->nelts == (queue)->bounds)
   
   /**
    * Detects when the fd_queue_t is empty. This utility function is expected
    * to be called from within critical sections, and is not threadsafe.
    */
  -#define ap_queue_empty(queue) ((queue)->tail == 0)
  +#define ap_queue_empty(queue) ((queue)->nelts == 0)
   
   /**
    * Callback routine that is called to destroy this
  @@ -107,9 +107,10 @@
           return rv;
       }
   
  -    queue->tail = 0;
  +    queue->head = queue->tail = 0;
       queue->data = apr_palloc(a, queue_capacity * sizeof(fd_queue_elem_t));
       queue->bounds = queue_capacity;
  +    queue->nelts = 0;
   
       /* Set all the sockets in the queue to NULL */
       for (i = 0; i < queue_capacity; ++i)
  @@ -146,9 +147,11 @@
           apr_thread_cond_wait(queue->not_full, queue->one_big_mutex);
       }
   
  -    elem = &queue->data[queue->tail++];
  +    elem = &queue->data[queue->tail];
  +    queue->tail = (queue->tail + 1) % queue->bounds;
       elem->sd = sd;
       elem->p = p;
  +    queue->nelts++;
   
       if (queue->num_recycled != 0) {
           *recycled_pool = queue->recycled_pools[--queue->num_recycled];
  @@ -209,15 +212,17 @@
               }
           }
       } 
  -    
  -    elem = &queue->data[--queue->tail];
  +
  +    elem = &queue->data[queue->head];
  +    queue->head = (queue->head + 1) % queue->bounds;
       *sd = elem->sd;
       *p = elem->p;
       elem->sd = NULL;
       elem->p = NULL;
  +    queue->nelts--;
   
       /* signal not_full if we were full before this pop */
  -    if (queue->tail == queue->bounds - 1) {
  +    if (queue->nelts == queue->bounds - 1) {
           apr_thread_cond_signal(queue->not_full);
       }
   
  
  
  
  1.16      +2 -0      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- fdqueue.h	21 Mar 2002 19:12:54 -0000	1.15
  +++ fdqueue.h	26 Apr 2002 17:13:51 -0000	1.16
  @@ -78,8 +78,10 @@
   typedef struct fd_queue_elem_t fd_queue_elem_t;
   
   struct fd_queue_t {
  +    int                 head;
       int                 tail;
       fd_queue_elem_t    *data;
  +    int                 nelts;
       int                 bounds;
       apr_thread_mutex_t *one_big_mutex;
       apr_thread_cond_t  *not_empty;