apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1828369 - in /apr/apr/trunk: include/apr_reslist.h util-misc/apr_reslist.c
Date Wed, 04 Apr 2018 17:43:46 GMT
Author: ylavic
Date: Wed Apr  4 17:43:46 2018
New Revision: 1828369

URL: http://svn.apache.org/viewvc?rev=1828369&view=rev
Log:
reslist: follow up to r1828289: adjust maintenance top too.

Also, clarify in doxygen when apr_reslist_fifo_set() should be called.


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

Modified: apr/apr/trunk/include/apr_reslist.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_reslist.h?rev=1828369&r1=1828368&r2=1828369&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_reslist.h (original)
+++ apr/apr/trunk/include/apr_reslist.h Wed Apr  4 17:43:46 2018
@@ -134,11 +134,17 @@ APR_DECLARE(apr_status_t) apr_reslist_re
  */
 APR_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,
                                           apr_interval_time_t timeout);
+
 /**
  * Set whether the reslist reuses resources as FIFO (First In First Out) or
  * LIFO (Last In First Out).
  * @param reslist The resource list.
  * @param fifo Set as FIFO (non zero) or LIFO (zero).
+ * @remark This function should be called before any resource is in the
+ * the reslist, otherwise maintenance optimizations based on the expiration
+ * time relative to the order of insertion (i.e. position in the list) won't
+ * work as expected.
+ *
  */
 APR_DECLARE(void) apr_reslist_fifo_set(apr_reslist_t *reslist, int fifo);
 

Modified: apr/apr/trunk/util-misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_reslist.c?rev=1828369&r1=1828368&r2=1828369&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_reslist.c (original)
+++ apr/apr/trunk/util-misc/apr_reslist.c Wed Apr  4 17:43:46 2018
@@ -229,8 +229,13 @@ APR_DECLARE(apr_status_t) apr_reslist_ma
     /* Check if we need to expire old resources */
     now = apr_time_now();
     while (reslist->nidle > reslist->smax && reslist->nidle > 0) {
-        /* Peak at the last resource in the list */
-        res = APR_RING_LAST(&reslist->avail_list);
+        /* Peek at the next expiring resource in the list */
+        if (reslist->fifo) {
+            res = APR_RING_FIRST(&reslist->avail_list);
+        }
+        else {
+            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



Mime
View raw message