apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 63632] New: reslist kills all idle connections when acquiring a new one, not considering smax value
Date Mon, 05 Aug 2019 08:01:11 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=63632

            Bug ID: 63632
           Summary: reslist kills all idle connections when acquiring a
                    new one, not considering smax value
           Product: APR
           Version: HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: j.brunod@inwind.it
  Target Milestone: ---

apr_reslist created with apr_reslist_create, and min, smax, and hmax values
equal for, let's say, 10, 10, 30, does not take into consideration the smax
value when killing idle connections, but only when acquiring new ones.

To reproduce: create a resource list with the above values, give it an idle
time of 5 seconds. Wait at least 5 seconds. Acquire a new connection. You will
see that 10 connections will be killed (bringing them down to zero) and 10 new
connections will be created. 

This is the code that does it (row 373, apr_reslist.c)

        apr_time_t now = apr_time_now();
        do {
            /* Peek at the oldest resource in the list */
            res = APR_RING_LAST(&reslist->avail_list);
            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;
            }

            /* this res is expired - kill it */
            APR_RING_REMOVE(res, link);
            reslist->nidle--;
            reslist->ntotal--;
            rv = destroy_resource(reslist, res);
            free_container(reslist, res);
            if (rv != APR_SUCCESS) {
#if APR_HAS_THREADS
                apr_thread_mutex_unlock(reslist->listlock);
#endif
                return rv;  /* FIXME: this might cause unnecessary fails */
            }
        } while (reslist->nidle > 0); <------------------This is the problem

In the reslist_maintain code, there is a similar section, but this time with
this while loop:
while(reslist->nidle > reslist->smax && reslist->nidle > 0) 
which I think is the right code to use. Why not simply use the reslist code
when acquiring, instead of copypasting maintenance code?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message