]> granicus.if.org Git - apache/commitdiff
Removed the "not_full" condition variable and associated conditional
authorBrian Pane <brianp@apache.org>
Sun, 28 Apr 2002 23:12:35 +0000 (23:12 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 28 Apr 2002 23:12:35 +0000 (23:12 +0000)
logic from the file descriptor queue, now that we can rely on the
idle worker reference count to keep the listener from trying to
push connections into a full queue
Reviewed by: Aaron Bannert (concept)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94845 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/worker/fdqueue.c
server/mpm/worker/fdqueue.h

index 362583986e136cdd4aa5d83d37c0bd5fbe7c2835..14c17e7ecf05924ff986f2822ad385c4beeed2e5 100644 (file)
@@ -214,7 +214,6 @@ static apr_status_t ap_queue_destroy(void *data)
      * XXX: We should at least try to signal an error here, it is
      * indicative of a programmer error. -aaron */
     apr_thread_cond_destroy(queue->not_empty);
-    apr_thread_cond_destroy(queue->not_full);
     apr_thread_mutex_destroy(queue->one_big_mutex);
 
     return APR_SUCCESS;
@@ -235,11 +234,7 @@ apr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a)
     if ((rv = apr_thread_cond_create(&queue->not_empty, a)) != APR_SUCCESS) {
         return rv;
     }
-    if ((rv = apr_thread_cond_create(&queue->not_full, a)) != APR_SUCCESS) {
-        return rv;
-    }
 
-    queue->head = queue->tail = 0;
     queue->data = apr_palloc(a, queue_capacity * sizeof(fd_queue_elem_t));
     queue->bounds = queue_capacity;
     queue->nelts = 0;
@@ -268,13 +263,9 @@ apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p)
     }
 
     AP_DEBUG_ASSERT(!queue->terminated);
-    
-    while (ap_queue_full(queue)) {
-        apr_thread_cond_wait(queue->not_full, queue->one_big_mutex);
-    }
+    AP_DEBUG_ASSERT(!ap_queue_full(queue));
 
-    elem = &queue->data[queue->tail];
-    queue->tail = (queue->tail + 1) % queue->bounds;
+    elem = &queue->data[queue->nelts];
     elem->sd = sd;
     elem->p = p;
     queue->nelts++;
@@ -323,18 +314,11 @@ apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p)
         }
     } 
 
-    elem = &queue->data[queue->head];
-    queue->head = (queue->head + 1) % queue->bounds;
+    elem = &queue->data[--queue->nelts];
     *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->nelts == queue->bounds - 1) {
-        apr_thread_cond_signal(queue->not_full);
-    }
 
     rv = apr_thread_mutex_unlock(queue->one_big_mutex);
     return rv;
@@ -348,9 +332,6 @@ apr_status_t ap_queue_interrupt_all(fd_queue_t *queue)
         return rv;
     }
     apr_thread_cond_broadcast(queue->not_empty);
-    /* We shouldn't have multiple threads sitting in not_full, but
-     * broadcast just in case. */
-    apr_thread_cond_broadcast(queue->not_full);
     if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) {
         return rv;
     }
index 4e72358188fd494a751f4ddad2975638ca4a4131..de76921f01e294a0fbd2a54f37e5b3bc0abd2050 100644 (file)
@@ -88,14 +88,11 @@ struct fd_queue_elem_t {
 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;
-    apr_thread_cond_t  *not_full;
     int                 terminated;
 };
 typedef struct fd_queue_t fd_queue_t;