You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2018/06/21 14:45:47 UTC

svn commit: r1834024 - /apr/apr/trunk/util-misc/apr_reslist.c

Author: ylavic
Date: Thu Jun 21 14:45:47 2018
New Revision: 1834024

URL: http://svn.apache.org/viewvc?rev=1834024&view=rev
Log:
apr_reslist: follow up to r1834023: avoid unnecessary apr_time_now() calls.

When ttl=0 is configured, we never need to check for expiry.

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

Modified: apr/apr/trunk/util-misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_reslist.c?rev=1834024&r1=1834023&r2=1834024&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_reslist.c (original)
+++ apr/apr/trunk/util-misc/apr_reslist.c Thu Jun 21 14:45:47 2018
@@ -81,7 +81,9 @@ static apr_res_t *pop_resource(apr_resli
 static void push_resource(apr_reslist_t *reslist, apr_res_t *resource)
 {
     APR_RING_INSERT_HEAD(&reslist->avail_list, resource, apr_res_t, link);
-    resource->freed = apr_time_now();
+    if (reslist->ttl) {
+        resource->freed = apr_time_now();
+    }
     reslist->nidle++;
 }
 
@@ -332,7 +334,7 @@ APR_DECLARE(apr_status_t) apr_reslist_ac
 {
     apr_status_t rv;
     apr_res_t *res;
-    apr_time_t now;
+    apr_time_t now = 0;
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
@@ -340,7 +342,9 @@ APR_DECLARE(apr_status_t) apr_reslist_ac
 #endif
     /* If there are idle resources on the available list, use
      * them right away. */
-    now = apr_time_now();
+    if (reslist->ttl) {
+        now = apr_time_now();
+    }
     while (reslist->nidle > 0) {
         /* Pop off the first resource */
         res = pop_resource(reslist);