From: Kurt Zeilenga Date: Thu, 28 Sep 2000 02:27:49 +0000 (+0000) Subject: fix up bdb_entry_return() calls X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1868 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=67a595b3284ba3f4b5e780dd90cbe38884093af9;p=openldap fix up bdb_entry_return() calls --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 8fbef95a97..03aba133d7 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -24,7 +24,7 @@ bdb_add( char *pdn = NULL; Entry *p = NULL; int rc; - const char *text = NULL; + const char *text; AttributeDescription *children = slap_schema.si_ad_children; DB_TXN *ltid = NULL; struct bdb_op_info opinfo; @@ -68,6 +68,7 @@ retry: rc = txn_abort( ltid ); /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_add: txn_begin failed: %s (%d)\n", @@ -119,6 +120,7 @@ retry: rc = txn_abort( ltid ); ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); + matched = NULL; } else { matched_dn = NULL; diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index bd9a8bf58f..e412216ed1 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -70,6 +70,8 @@ bdb_bind( : NULL; bdb_entry_return( be, matched ); + matched = NULL; + } else { refs = default_referral; } @@ -240,7 +242,9 @@ bdb_bind( done: /* free entry and reader lock */ - bdb_entry_return( be, e ); + if( e != NULL ) { + bdb_entry_return( be, e ); + } /* front end with send result on success (rc==0) */ return rc; diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index 2764cdf9e8..c60d688995 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -53,6 +53,8 @@ bdb_compare( ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); + matched = NULL; + } else { refs = default_referral; } @@ -117,7 +119,9 @@ return_results: done: /* free entry */ - if( e != NULL ) bdb_entry_return( be, e ); + if( e != NULL ) { + bdb_entry_return( be, e ); + } return rc; } \ No newline at end of file diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 01e636f6e9..b069107384 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -27,7 +27,7 @@ bdb_delete( char *pdn = NULL; Entry *e, *p = NULL; int rc; - const char *text = NULL; + const char *text; int manageDSAit = get_manageDSAit( op ); AttributeDescription *children = slap_schema.si_ad_children; DB_TXN *ltid = NULL; @@ -50,6 +50,7 @@ retry: /* transaction retry */ /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_delete: txn_begin failed: %s (%d)\n", @@ -94,6 +95,8 @@ retry: /* transaction retry */ ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); + matched = NULL; + } else { refs = default_referral; } @@ -145,6 +148,7 @@ retry: /* transaction retry */ children, NULL, ACL_WRITE ); bdb_entry_return( be, p ); + p = NULL; if ( !rc ) { Debug( LDAP_DEBUG_TRACE, @@ -267,7 +271,9 @@ return_results: done: /* free entry */ - if( e != NULL ) bdb_entry_return( be, e ); + if( e != NULL ) { + bdb_entry_return( be, e ); + } if( ltid != NULL ) { txn_abort( ltid ); diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index edc0e241a5..d3e03423af 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -191,7 +191,7 @@ bdb_idl_insert_key( data.ulen = sizeof( ids ); data.flags = DB_DBT_USERMEM; - /* fetch the key and grab a write lock */ + /* fetch the key for read/modify/write */ rc = db->get( db, tid, key, &data, DB_RMW ); if( rc == DB_NOTFOUND ) { @@ -279,7 +279,7 @@ bdb_idl_delete_key( data.ulen = sizeof( ids ); data.flags = DB_DBT_USERMEM; - /* fetch the key and grab a write lock */ + /* fetch the key for read/modify/write */ rc = db->get( db, tid, key, &data, DB_RMW ); if ( rc != 0 ) { diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 24b45759e9..100fb8ebb4 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -175,6 +175,7 @@ retry: /* transaction retry */ /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_modify: txn_begin failed: %s (%d)\n", @@ -220,6 +221,7 @@ retry: /* transaction retry */ ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); + matched = NULL; } else { refs = default_referral; @@ -311,7 +313,9 @@ done: op->o_private = NULL; } - bdb_entry_return( be, e ); + if( e != NULL ) { + bdb_entry_return( be, e ); + } return rc; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 36c1bed49c..39e9fd1eb2 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -32,7 +32,7 @@ bdb_modrdn( Entry *e, *p = NULL; Entry *matched; int rc; - const char *text = NULL; + const char *text; DB_TXN * ltid; struct bdb_op_info opinfo; @@ -72,8 +72,10 @@ retry: rc = txn_abort( ltid ); } } + /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_delete: txn_begin failed: %s (%d)\n", @@ -114,6 +116,8 @@ retry: rc = txn_abort( ltid ); ? get_entry_referrals( be, conn, op, matched ) : NULL; bdb_entry_return( be, matched ); + matched = NULL; + } else { refs = default_referral; } @@ -428,6 +432,11 @@ retry: rc = txn_abort( ltid ); /* delete old one */ rc = bdb_dn2id_delete( be, ltid, e->e_ndn, e->e_id ); if ( rc != 0 ) { + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } rc = LDAP_OTHER; text = "DN index delete fail"; goto return_results; @@ -443,6 +452,11 @@ retry: rc = txn_abort( ltid ); /* add new one */ rc = bdb_dn2id_add( be, ltid, e->e_ndn, e->e_id ); if ( rc != 0 ) { + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } rc = LDAP_OTHER; text = "DN index add failed"; goto return_results; @@ -452,6 +466,11 @@ retry: rc = txn_abort( ltid ); rc = bdb_modify_internal( be, conn, op, ltid, &mod[0], e, &text ); if( rc != LDAP_SUCCESS ) { + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } goto return_results; } @@ -460,15 +479,18 @@ retry: rc = txn_abort( ltid ); */ /* id2entry index */ - rc = bdb_id2entry_add( be, ltid, e ); + rc = bdb_id2entry_update( be, ltid, e ); if ( rc != 0 ) { + switch( rc ) { + case DB_LOCK_DEADLOCK: + case DB_LOCK_NOTGRANTED: + goto retry; + } rc = LDAP_OTHER; text = "entry update failed"; goto return_results; } - rc = LDAP_SUCCESS; - rc = txn_commit( ltid, 0 ); ltid = NULL; op->o_private = NULL; diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 09b4bc4ed5..fa993077c8 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -73,7 +73,7 @@ bdb_exop_passwd( dn = id ? id->bv_val : op->o_dn; - Debug( LDAP_DEBUG_TRACE, "passwd: \"%s\"%s\n", + Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: \"%s\"%s\n", dn, id ? " (proxy)" : "", 0 ); if( dn == NULL || dn[0] == '\0' ) { @@ -83,8 +83,9 @@ bdb_exop_passwd( } if (0) { - /* transaction retry */ -retry: rc = txn_abort( ltid ); +retry: /* transaction retry */ + Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: retrying...\n", 0, 0, 0 ); + rc = txn_abort( ltid ); ltid = NULL; op->o_private = NULL; if( rc != 0 ) { @@ -96,6 +97,7 @@ retry: rc = txn_abort( ltid ); /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); + *text = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: txn_begin failed: %s (%d)\n", @@ -185,6 +187,7 @@ retry: rc = txn_abort( ltid ); case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: bdb_entry_return( be, e ); + e = NULL; goto retry; } *text = "entry update failed"; diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index b969ce966f..92fac42779 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -67,6 +67,7 @@ bdb_referrals( : NULL; bdb_entry_return( be, matched ); + matched = NULL; } if( refs != NULL ) { diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 2fb50d5977..629ab39d3e 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -107,6 +107,7 @@ bdb_search( ber_bvecfree( refs ); free( matched_dn ); bdb_entry_return( be, matched ); + matched = NULL; } return rc; @@ -119,6 +120,7 @@ bdb_search( conn, op, e ); bdb_entry_return( be, e ); + e = NULL; Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n", 0, 0, 0 ); @@ -162,6 +164,7 @@ bdb_search( cursor = e->e_id; bdb_entry_return( be, e ); + e = NULL; if ( candidates[0] == 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_search: no candidates\n", @@ -303,6 +306,7 @@ bdb_search( /* check size limit */ if ( --slimit == -1 ) { bdb_entry_return( be, e ); + e = NULL; send_search_result( conn, op, rc = LDAP_SIZELIMIT_EXCEEDED, NULL, NULL, v2refs, NULL, nentries ); @@ -321,6 +325,7 @@ bdb_search( break; case -1: /* connection closed */ bdb_entry_return( be, e ); + e = NULL; rc = LDAP_OTHER; goto done; }