httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/worker fdqueue.c fdqueue.h
Date Wed, 17 Oct 2001 16:29:37 GMT
aaron       01/10/17 09:29:37

  Modified:    server/mpm/worker fdqueue.c fdqueue.h
  Log:
  Fully convert worker's fdqueue to the new APR lock API:
  - Mutexes and Condition Variables from APR are now used instead of
    direct (non-portable) calls to pthread.
  
  Still need to fully APRize these routines, particularly the return
  values. In many cases a failed lock or cond var call will simply return
  FD_QUEUE_FAILURE. This should obviously instead return the appropriate
  APR error code.
  
  Revision  Changes    Path
  1.9       +21 -19    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- fdqueue.c	2001/10/01 19:37:20	1.8
  +++ fdqueue.c	2001/10/17 16:29:36	1.9
  @@ -81,9 +81,9 @@
       /* Ignore errors here, we can't do anything about them anyway.
        * 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);
  +    apr_thread_cond_destroy(queue->not_empty);
  +    apr_thread_cond_destroy(queue->not_full);
  +    apr_thread_mutex_destroy(queue->one_big_mutex);
   
       return FD_QUEUE_SUCCESS;
   }
  @@ -95,11 +95,13 @@
   {
       int i;
   
  -    if (pthread_mutex_init(&queue->one_big_mutex, NULL) != 0)
  +    /* FIXME: APRize these return values. */
  +    if (apr_thread_mutex_create(&queue->one_big_mutex,
  +                              APR_THREAD_MUTEX_DEFAULT, a) != APR_SUCCESS)
           return FD_QUEUE_FAILURE;
  -    if (pthread_cond_init(&queue->not_empty, NULL) != 0)
  +    if (apr_thread_cond_create(&queue->not_empty, a) != APR_SUCCESS)
           return FD_QUEUE_FAILURE;
  -    if (pthread_cond_init(&queue->not_full, NULL) != 0)
  +    if (apr_thread_cond_create(&queue->not_full, a) != APR_SUCCESS)
           return FD_QUEUE_FAILURE;
   
       queue->tail = 0;
  @@ -124,21 +126,21 @@
   {
       fd_queue_elem_t *elem;
   
  -    if (pthread_mutex_lock(&queue->one_big_mutex) != 0) {
  +    if (apr_thread_mutex_lock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
   
       while (ap_queue_full(queue)) {
  -        pthread_cond_wait(&queue->not_full, &queue->one_big_mutex);
  +        apr_thread_cond_wait(queue->not_full, queue->one_big_mutex);
       }
   
       elem = &queue->data[queue->tail++];
       elem->sd = sd;
       elem->p = p;
   
  -    pthread_cond_signal(&queue->not_empty);
  +    apr_thread_cond_signal(queue->not_empty);
   
  -    if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
  +    if (apr_thread_mutex_unlock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
   
  @@ -155,16 +157,16 @@
   {
       fd_queue_elem_t *elem;
   
  -    if (pthread_mutex_lock(&queue->one_big_mutex) != 0) {
  +    if (apr_thread_mutex_lock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
   
       /* Keep waiting until we wake up and find that the queue is not empty. */
       if (ap_queue_empty(queue)) {
  -        pthread_cond_wait(&queue->not_empty, &queue->one_big_mutex);
  +        apr_thread_cond_wait(queue->not_empty, queue->one_big_mutex);
           /* If we wake up and it's still empty, then we were interrupted */
           if (ap_queue_empty(queue)) {
  -            if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
  +            if (apr_thread_mutex_unlock(queue->one_big_mutex) != APR_SUCCESS) {
                   return FD_QUEUE_FAILURE;
               }
               return FD_QUEUE_EINTR;
  @@ -179,10 +181,10 @@
   
       /* signal not_full if we were full before this pop */
       if (queue->tail == queue->bounds - 1) {
  -        pthread_cond_signal(&queue->not_full);
  +        apr_thread_cond_signal(queue->not_full);
       }
   
  -    if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
  +    if (apr_thread_mutex_unlock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
   
  @@ -191,14 +193,14 @@
   
   apr_status_t ap_queue_interrupt_all(fd_queue_t *queue)
   {
  -    if (pthread_mutex_lock(&queue->one_big_mutex) != 0) {
  +    if (apr_thread_mutex_lock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
  -    pthread_cond_broadcast(&queue->not_empty);
  +    apr_thread_cond_broadcast(queue->not_empty);
       /* We shouldn't have multiple threads sitting in not_full, but
        * broadcast just in case. */
  -    pthread_cond_broadcast(&queue->not_full);
  -    if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
  +    apr_thread_cond_broadcast(queue->not_full);
  +    if (apr_thread_mutex_unlock(queue->one_big_mutex) != APR_SUCCESS) {
           return FD_QUEUE_FAILURE;
       }
       return FD_QUEUE_SUCCESS;
  
  
  
  1.9       +11 -9     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- fdqueue.h	2001/10/01 19:37:20	1.8
  +++ fdqueue.h	2001/10/17 16:29:37	1.9
  @@ -63,7 +63,8 @@
   #if APR_HAVE_UNISTD_H
   #include <unistd.h>
   #endif
  -#include <pthread.h>
  +#include <apr_thread_mutex.h>
  +#include <apr_thread_cond.h>
   #include <sys/types.h>
   #include <sys/socket.h>
   #include <apr_errno.h>
  @@ -80,17 +81,18 @@
   typedef struct fd_queue_elem_t fd_queue_elem_t;
   
   struct fd_queue_t {
  -    int                tail;
  -    fd_queue_elem_t   *data;
  -    int                bounds;
  -    int                blanks;
  -    pthread_mutex_t    one_big_mutex;
  -    pthread_cond_t     not_empty;
  -    pthread_cond_t     not_full;
  -    int                cancel_state;
  +    int                 tail;
  +    fd_queue_elem_t    *data;
  +    int                 bounds;
  +    int                 blanks;
  +    apr_thread_mutex_t *one_big_mutex;
  +    apr_thread_cond_t  *not_empty;
  +    apr_thread_cond_t  *not_full;
  +    int                 cancel_state;
   };
   typedef struct fd_queue_t fd_queue_t;
   
  +/* FIXME: APRize these -- return values should be apr_status_t */
   int ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a);
   int ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p);
   apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p);
  
  
  

Mime
View raw message