~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/back-bdb/cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090907134110-jsdrvn0atu1fex4m
Tags: upstream-2.4.18
ImportĀ upstreamĀ versionĀ 2.4.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* cache.c - routines to maintain an in-core cache of entries */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/cache.c,v 1.120.2.31 2009/06/19 21:55:57 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/cache.c,v 1.120.2.32 2009/07/27 17:38:40 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
5
 * Copyright 2000-2009 The OpenLDAP Foundation.
689
689
{
690
690
        DB_LOCK         lock, *lockp;
691
691
        EntryInfo *elru, *elnext = NULL;
692
 
        int count, islocked, eimax;
693
 
        int efree = 0, eifree = 0, eicount, ecount;
 
692
        int islocked;
 
693
        ID eicount, ecount;
 
694
        ID count, efree, eifree = 0;
694
695
#ifdef LDAP_DEBUG
695
696
        int iter;
696
697
#endif
698
699
        /* Wait for the mutex; we're the only one trying to purge. */
699
700
        ldap_pvt_thread_mutex_lock( &bdb->bi_cache.c_lru_mutex );
700
701
 
 
702
        if ( bdb->bi_cache.c_cursize > bdb->bi_cache.c_maxsize ) {
 
703
                efree = bdb->bi_cache.c_cursize - bdb->bi_cache.c_maxsize;
 
704
                efree += bdb->bi_cache.c_minfree;
 
705
        } else {
 
706
                efree = 0;
 
707
        }
 
708
 
701
709
        /* maximum number of EntryInfo leaves to cache. In slapcat
702
710
         * we always free all leaf nodes.
703
711
         */
704
 
        if ( slapMode & SLAP_TOOL_READONLY )
705
 
                eimax = 0;
706
 
        else
707
 
                eimax = bdb->bi_cache.c_eimax;
708
 
 
709
 
        efree = bdb->bi_cache.c_cursize - bdb->bi_cache.c_maxsize;
710
 
        if ( efree < 1 )
711
 
                efree = 0;
712
 
        else 
713
 
                efree += bdb->bi_cache.c_minfree;
714
 
 
715
 
        if ( bdb->bi_cache.c_leaves > eimax ) {
 
712
 
 
713
        if ( slapMode & SLAP_TOOL_READONLY ) {
 
714
                eifree = bdb->bi_cache.c_leaves;
 
715
        } else if ( bdb->bi_cache.c_eimax &&
 
716
                bdb->bi_cache.c_leaves > bdb->bi_cache.c_eimax ) {
716
717
                eifree = bdb->bi_cache.c_minfree * 10;
717
 
                if ( eifree >= eimax )
718
 
                        eifree = eimax / 2;
 
718
                if ( eifree >= bdb->bi_cache.c_leaves )
 
719
                        eifree /= 2;
719
720
        }
720
721
 
721
722
        if ( !efree && !eifree ) {
1065
1066
                int purge = 0;
1066
1067
 
1067
1068
                if ( bdb->bi_cache.c_cursize > bdb->bi_cache.c_maxsize ||
1068
 
                        bdb->bi_cache.c_leaves > bdb->bi_cache.c_eimax ) {
 
1069
                        ( bdb->bi_cache.c_eimax && bdb->bi_cache.c_leaves > bdb->bi_cache.c_eimax )) {
1069
1070
                        ldap_pvt_thread_mutex_lock( &bdb->bi_cache.c_count_mutex );
1070
1071
                        if ( !bdb->bi_cache.c_purging ) {
1071
1072
                                if ( load && !( flag & ID_NOCACHE )) {
1074
1075
                                                purge = 1;
1075
1076
                                                bdb->bi_cache.c_purging = 1;
1076
1077
                                        }
1077
 
                                } else if ( bdb->bi_cache.c_leaves > bdb->bi_cache.c_eimax ) {
 
1078
                                } else if ( bdb->bi_cache.c_eimax && bdb->bi_cache.c_leaves > bdb->bi_cache.c_eimax ) {
1078
1079
                                        purge = 1;
1079
1080
                                        bdb->bi_cache.c_purging = 1;
1080
1081
                                }