mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
partial revert - keep acquiring BDB lock in lru_purge.
This commit is contained in:
parent
b8309b4cf8
commit
d7fa1e764d
@ -127,6 +127,7 @@ typedef struct bdb_cache {
|
|||||||
int c_minfree;
|
int c_minfree;
|
||||||
int c_eiused; /* EntryInfo's in use */
|
int c_eiused; /* EntryInfo's in use */
|
||||||
int c_leaves; /* EntryInfo leaf nodes */
|
int c_leaves; /* EntryInfo leaf nodes */
|
||||||
|
u_int32_t c_locker; /* used by lru cleaner */
|
||||||
EntryInfo c_dntree;
|
EntryInfo c_dntree;
|
||||||
EntryInfo *c_eifree; /* free list */
|
EntryInfo *c_eifree; /* free list */
|
||||||
Avlnode *c_idtree;
|
Avlnode *c_idtree;
|
||||||
|
@ -556,6 +556,7 @@ int hdb_cache_load(
|
|||||||
static void
|
static void
|
||||||
bdb_cache_lru_purge( struct bdb_info *bdb )
|
bdb_cache_lru_purge( struct bdb_info *bdb )
|
||||||
{
|
{
|
||||||
|
DB_LOCK lock, *lockp;
|
||||||
EntryInfo *elru, *elnext;
|
EntryInfo *elru, *elnext;
|
||||||
int count, islocked;
|
int count, islocked;
|
||||||
|
|
||||||
@ -568,6 +569,12 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( bdb->bi_cache.c_locker ) {
|
||||||
|
lockp = &lock;
|
||||||
|
} else {
|
||||||
|
lockp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
/* Look for an unused entry to remove */
|
/* Look for an unused entry to remove */
|
||||||
for (elru = bdb->bi_cache.c_lruhead; elru; elru = elnext ) {
|
for (elru = bdb->bi_cache.c_lruhead; elru; elru = elnext ) {
|
||||||
@ -592,8 +599,15 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* entryinfo is locked */
|
||||||
islocked = 1;
|
islocked = 1;
|
||||||
|
|
||||||
|
/* If we can successfully writelock it, then
|
||||||
|
* the object is idle.
|
||||||
|
*/
|
||||||
|
if ( bdb_cache_entry_db_lock( bdb->bi_dbenv,
|
||||||
|
bdb->bi_cache.c_locker, elru, 1, 1, lockp ) == 0 ) {
|
||||||
|
|
||||||
/* Free entry for this node if it's present */
|
/* Free entry for this node if it's present */
|
||||||
if ( elru->bei_e ) {
|
if ( elru->bei_e ) {
|
||||||
elru->bei_e->e_private = NULL;
|
elru->bei_e->e_private = NULL;
|
||||||
@ -605,6 +619,8 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
|||||||
elru->bei_e = NULL;
|
elru->bei_e = NULL;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
bdb_cache_entry_dbunlock( bdb, lockp );
|
||||||
|
|
||||||
/* ITS#4010 if we're in slapcat, and this node is a leaf
|
/* ITS#4010 if we're in slapcat, and this node is a leaf
|
||||||
* node, free it.
|
* node, free it.
|
||||||
*
|
*
|
||||||
@ -620,6 +636,7 @@ bdb_cache_lru_purge( struct bdb_info *bdb )
|
|||||||
}
|
}
|
||||||
/* Leave node on LRU list for a future pass */
|
/* Leave node on LRU list for a future pass */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( islocked )
|
if ( islocked )
|
||||||
bdb_cache_entryinfo_unlock( elru );
|
bdb_cache_entryinfo_unlock( elru );
|
||||||
|
@ -423,6 +423,10 @@ bdb_db_open( BackendDB *be )
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !quick ) {
|
||||||
|
XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
|
||||||
|
}
|
||||||
|
|
||||||
/* monitor setup */
|
/* monitor setup */
|
||||||
rc = bdb_monitor_db_open( be );
|
rc = bdb_monitor_db_open( be );
|
||||||
if ( rc != 0 ) {
|
if ( rc != 0 ) {
|
||||||
@ -486,6 +490,12 @@ bdb_db_close( BackendDB *be )
|
|||||||
|
|
||||||
/* close db environment */
|
/* close db environment */
|
||||||
if( bdb->bi_dbenv ) {
|
if( bdb->bi_dbenv ) {
|
||||||
|
/* Free cache locker if we enabled locking */
|
||||||
|
if ( !( slapMode & SLAP_TOOL_QUICK )) {
|
||||||
|
XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
|
||||||
|
bdb->bi_cache.c_locker = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* force a checkpoint, but not if we were ReadOnly,
|
/* force a checkpoint, but not if we were ReadOnly,
|
||||||
* and not in Quick mode since there are no transactions there.
|
* and not in Quick mode since there are no transactions there.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user