]> granicus.if.org Git - apache/commitdiff
Move a potentially expensive pool cleanup operation outside
authorBrian Pane <brianp@apache.org>
Sun, 28 Apr 2002 03:32:10 +0000 (03:32 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 28 Apr 2002 03:32:10 +0000 (03:32 +0000)
the mutex-protected critical path of ap_queue_pop()

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

server/mpm/worker/fdqueue.c

index 7d9263ff01474777dc7a83f291b7562e9b72a154..673a3927a1b31e9896c0f6b00e206082cd9e0800 100644 (file)
@@ -286,6 +286,7 @@ apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p,
 {
     fd_queue_elem_t *elem;
     apr_status_t rv;
+    int delete_pool = 0;
 
     if ((rv = apr_thread_mutex_lock(queue->one_big_mutex)) != APR_SUCCESS) {
         if (recycled_pool) {
@@ -299,7 +300,7 @@ apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p,
             queue->recycled_pools[queue->num_recycled++] = recycled_pool;
         }
         else {
-            apr_pool_destroy(recycled_pool);
+            delete_pool = 1;
         }
     }
 
@@ -311,8 +312,14 @@ apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p,
         /* If we wake up and it's still empty, then we were interrupted */
         if (ap_queue_empty(queue)) {
             if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) {
+                if (delete_pool) {
+                    apr_pool_destroy(recycled_pool);
+                }
                 return rv;
             }
+            if (delete_pool) {
+                apr_pool_destroy(recycled_pool);
+            }
             if (queue->terminated) {
                 return APR_EOF; /* no more elements ever again */
             }