httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jess Holle <je...@ptc.com>
Subject Re: Apache 2.0.51 util_ldap
Date Sun, 19 Sep 2004 19:06:19 GMT
Here's a fixed LDAP purge routine which works great in my testing (with 
cache sizes of 8, 100, 1000, and 2150 and 2500 unique user logins 
repeated 3 times each).  [No, I haven't produced a diff as I have pieces 
of util_ldap from various CVS levels at this point.]

Essentially I added all the logic surrounding 'pp', which is the address 
of the previous node's 'next' field or of cache->nodes[i] in the case of 
the first node.  [Cleary my C is getting rusty -- this took me a few 
attempts to get right...]

This fixes the biggest LDAP module issue I'm aware of: hangs and crashes 
after one or more cache purges.

--
Jess Holle

    void util_ald_cache_purge(util_ald_cache_t *cache)
    {
        unsigned long i;
        util_cache_node_t *p, *q, **pp;
        apr_time_t t;

        if (!cache)
            return;
     
        cache->last_purge = apr_time_now();
        cache->npurged = 0;
        cache->numpurges++;

        for (i=0; i < cache->size; ++i) {
            pp = cache->nodes + i;
            p = *pp;
            while (p != NULL) {
                if (p->add_time < cache->marktime) {
                    q = p->next;
                    (*cache->free)(cache, p->payload);
                    util_ald_free(cache, p);
                    cache->numentries--;
                    cache->npurged++;
                    p = *pp = q;
                }
                else {
                    pp = &(p->next);
                    p = *pp;
                }
            }
        }

        t = apr_time_now();
        cache->avg_purgetime =
             ((t - cache->last_purge) + (cache->avg_purgetime *
    (cache->numpurges-1))) /
             cache->numpurges;
    }

Jess Holle wrote:

> Graham Leggett wrote:
>
>> Jess Holle wrote:
>>
>>> I now see what's wrong with the LDAP cache purge -- it does not fix 
>>> up the 'next' pointers and/or cache->node[i] pointers when removing 
>>> entries -- and thus cannot hope to work.
>>>
>>> Unfortunately, my fixes for this are still falling short, but I 
>>> thought I'd pass this along.
>>
>>
>>
>> Looking at the previous fix, some of these problems seem to be fixed 
>> in HEAD. There was a batch of changes to the LDAP stuff that depended 
>> on v1.0 of APR, and were thus not backported to httpd v2.0.
>>
>> There may be some value in checking the diffs between HEAD and 2.0 to 
>> see what changes have been made - I think there are some bugfixes in 
>> there that need porting.
>
>
> Thanks for the tip.
>
> The purge() routine is still not fixed in HEAD, though...
>
> -- 
> Jess Holle



Mime
View raw message