On Sun, Apr 28, 2002 at 03:32:10AM -0000, [EMAIL PROTECTED] wrote:
> brianp      02/04/27 20:32:10
> 
>   Modified:    server/mpm/worker fdqueue.c
>   Log:
>   Move a potentially expensive pool cleanup operation outside
>   the mutex-protected critical path of ap_queue_pop()
>   
>   Revision  Changes    Path
>   1.18      +8 -1      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.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- fdqueue.c       28 Apr 2002 03:20:06 -0000      1.17
>   +++ fdqueue.c       28 Apr 2002 03:32:10 -0000      1.18
>   @@ -286,6 +286,7 @@
>    {
>        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 @@
>                queue->recycled_pools[queue->num_recycled++] = recycled_pool;
>            }
>            else {
>   -            apr_pool_destroy(recycled_pool);
>   +            delete_pool = 1;
>            }
>        }
>    
>   @@ -311,7 +312,13 @@
>            /* 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);
>                }

Something simpler might be:

rv = apr_thread_mutex_unlock(queue->one_big_mutex);
if (delete_pool) {
   apr_pool_destroy(recycled_pool);
}
if (rv != APR_SUCCESS) {
   return rv;
}

I dunno, but it seems much simpler and prevents duplicitious
code.  -- justin

Reply via email to