To expand a bit...

On Sat, Apr 14, 2018 at 1:46 AM, Yann Ylavic <ylavic....@gmail.com> wrote:
> On Sat, Apr 14, 2018 at 12:54 AM, Nick Kew <n...@apache.org> wrote:
>>
>>> On 13 Apr 2018, at 21:46, Yann Ylavic <ylavic....@gmail.com> wrote:
>>>
>>> On Fri, Apr 13, 2018 at 7:30 PM, William A Rowe Jr <wr...@rowe-clan.net> 
>>> wrote:
>>>> I'm still unclear why you believe we need APR to purge the elts when the
>>>> user chooses to flip the fifo/lifo switch. That seems very wrong to me, the
>>>> consumer can do so if that is what they desire.
>>>
>>> To be clear (with myself):
>>>
>>> /* What we have */
>>> APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist,
>>>                                              void **resource);
>>> /* What we want */
>>> #define apr_reslist_acquire_lifo apr_reslist_acquire
>>> APU_DECLARE(apr_status_t) apr_reslist_acquire_fifo(apr_reslist_t *reslist,
>>>                                                   void **resource);
>>
>> You have a plan to implement that with the existing structs?
>
> I'm almost there yes, see attached patch (no tested yet..).

The #if 0s there should always be 1s IMHO, and when the ttl is to be
checked against the resource we should always peek it as LIFO (i.e.
s/fifo/1/ in the first peek_resource() of reslist_acquire() in my
patch).
This would prevent starvation, and we should possibly do that in 1.6.x
too (where apr_reslist_acquire_fifo() can't land).
If we do that unconditionnaly, this patch is moot. After all,
apr_reslist_maintain() and/hence apr_reslist_release() are already
LIFO for recycling resources.

(Note that there is a bug in apr_reslist_maintain() which doesn't
check if ttl != 0 before expiring resources, hence kills everything
between smax and hmax. I have a unit test and plan to commit a fix
later).

>
>> How does it work if an application mixes the two forms of
>> acquire randomly, as seems likely if (for example) a reslist is
>> shared between applications/components of differing provenances?

If finally we need this patch and apr_reslist_acquire_fifo() gets used
arbitrarily/concurrently with the non-fifo version, we'd still recycle
resources appropriately in order, so I see no issue. Anything besides
the performance concern (which isn't one I think)?


Regards,
Yann.

Reply via email to