You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rp...@apache.org on 2007/08/13 11:11:04 UTC

svn commit: r565277 - in /apr/apr-util/branches/1.2.x: CHANGES misc/apr_reslist.c

Author: rpluem
Date: Mon Aug 13 02:11:02 2007
New Revision: 565277

URL: http://svn.apache.org/viewvc?view=rev&rev=565277
Log:
Merge r563103 from trunk:

* 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/branches/1.2.x/CHANGES
    apr/apr-util/branches/1.2.x/misc/apr_reslist.c

Modified: apr/apr-util/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/CHANGES?view=diff&rev=565277&r1=565276&r2=565277
==============================================================================
--- apr/apr-util/branches/1.2.x/CHANGES (original)
+++ apr/apr-util/branches/1.2.x/CHANGES Mon Aug 13 02:11:02 2007
@@ -1,5 +1,9 @@
 Changes with APR-util 1.2.9
 
+  *) Ensure that an apr_reslist shrinks back to SMAX via the TTL by
+     reorganising the resource list from a queue to a stack.
+     PR 40348.  [Christian BOITEL <christian_boitel yahoo.fr>]
+
   *) Fix Solaris 2.8+ fdatasync() detection. The fdatasync() function
      is marked as part of the Realtime library functions.
      PR 37343.  [Davi Arnaut]

Modified: apr/apr-util/branches/1.2.x/misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/misc/apr_reslist.c?view=diff&rev=565277&r1=565276&r2=565277
==============================================================================
--- apr/apr-util/branches/1.2.x/misc/apr_reslist.c (original)
+++ apr/apr-util/branches/1.2.x/misc/apr_reslist.c Mon Aug 13 02:11:02 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);