apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r563103 - /apr/apr-util/trunk/misc/apr_reslist.c
Date Mon, 06 Aug 2007 10:47:29 GMT
Author: rpluem
Date: Mon Aug  6 03:47:28 2007
New Revision: 563103

URL: http://svn.apache.org/viewvc?view=rev&rev=563103
Log:
* Ensure the shrinking of the pool back to SMAX via the TTL by reorganising  
  the resource list from a queue to a stack.

PR: 40348
Submitted by: Christian BOITEL <christian_boitel yahoo.fr>
Reviewed by: rpluem 

Modified:
    apr/apr-util/trunk/misc/apr_reslist.c

Modified: apr/apr-util/trunk/misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/misc/apr_reslist.c?view=diff&rev=563103&r1=563102&r2=563103
==============================================================================
--- apr/apr-util/trunk/misc/apr_reslist.c (original)
+++ apr/apr-util/trunk/misc/apr_reslist.c Mon Aug  6 03:47:28 2007
@@ -74,13 +74,13 @@
 }
 
 /**
- * Add a resource to the end of the list, set the time at which
+ * Add a resource to the beginning of the list, set the time at which
  * it was added to the list.
  * Assumes: that the reslist is locked.
  */
 static void push_resource(apr_reslist_t *reslist, apr_res_t *resource)
 {
-    APR_RING_INSERT_TAIL(&reslist->avail_list, resource, apr_res_t, link);
+    APR_RING_INSERT_HEAD(&reslist->avail_list, resource, apr_res_t, link);
     resource->freed = apr_time_now();
     reslist->nidle++;
 }
@@ -206,15 +206,16 @@
     /* Check if we need to expire old resources */
     now = apr_time_now();
     while (reslist->nidle > reslist->smax && reslist->nidle > 0) {
-        /* Peak at the first resource in the list */
-        res = APR_RING_FIRST(&reslist->avail_list);
+        /* Peak at the last resource in the list */
+        res = APR_RING_LAST(&reslist->avail_list);
         /* See if the oldest entry should be expired */
         if (now - res->freed < reslist->ttl) {
             /* If this entry is too young, none of the others
              * will be ready to be expired either, so we are done. */
             break;
         }
-        res = pop_resource(reslist);
+        APR_RING_REMOVE(res, link);
+        reslist->nidle--;
         reslist->ntotal--;
         rv = destroy_resource(reslist, res);
         free_container(reslist, res);



Mime
View raw message