From 06f3bfb7f9c2a765189db2f43bb2857e5d37f68b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 16 Jun 2004 03:29:02 +0000 Subject: [PATCH] More for ITS#3188 --- servers/slapd/back-bdb/cache.c | 15 +++++++++++---- servers/slapd/back-bdb/delete.c | 7 ++++++- servers/slapd/back-bdb/modrdn.c | 7 ++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index ab8a71feea..6002a9b83d 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -794,7 +794,7 @@ bdb_cache_modify( DB_LOCK *lock ) { EntryInfo *ei = BEI(e); - int rc = 0; + int rc; /* Get write lock on data */ rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); @@ -825,10 +825,11 @@ bdb_cache_modrdn( { EntryInfo *ei = BEI(e), *pei; struct berval rdn; - int rc = 0; + int rc; /* Get write lock on data */ - bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); + rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); + if ( rc ) return rc; /* If we've done repeated mods on a cached entry, then e_attrs * is no longer contiguous with the entry, and must be freed. @@ -911,7 +912,13 @@ bdb_cache_delete( bdb_cache_entryinfo_lock( ei ); /* Get write lock on the data */ - bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); + rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); + if ( rc ) { + /* couldn't lock, undo and give up */ + ei->bei_state ^= CACHE_ENTRY_DELETED; + bdb_cache_entryinfo_unlock( ei ); + return rc; + } /* set cache write lock */ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock ); diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 84758b89f8..cdd614bb4c 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -545,8 +545,13 @@ retry: /* transaction retry */ goto return_results; } } else { - bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv, + rc = bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv, locker, &lock ); + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { if ( ctxcsn_added ) { diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index ed817dedb8..749f6571de 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -1017,8 +1017,13 @@ retry: /* transaction retry */ } } else { - bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip, + rc = bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip, bdb->bi_dbenv, locker, &lock ); + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { if ( ctxcsn_added ) { -- 2.39.5