Entry *e = NULL;
Entry *matched = NULL;
+ u_int32_t locker;
+ DB_LOCK lock;
+
if( op->o_tag == LDAP_REQ_SEARCH ) {
/* let search take care of itself */
return rc;
return rc;
}
+ LOCK_ID ( bdb->bi_dbenv, &locker );
+
+dn2entry_retry:
/* get entry */
- rc = bdb_dn2entry_r( be, NULL, ndn, &e, &matched, 0 );
+ rc = bdb_dn2entry_r( be, NULL, ndn, &e, &matched, 0, locker, &lock );
switch(rc) {
case DB_NOTFOUND:
break;
case LDAP_BUSY:
if (e != NULL) {
- bdb_cache_return_entry_r(&bdb->bi_cache, e);
+ bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
}
if (matched != NULL) {
- bdb_cache_return_entry_r(&bdb->bi_cache, matched);
+ bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, matched, &lock);
}
send_ldap_result( conn, op, LDAP_BUSY,
NULL, "ldap server busy", NULL, NULL );
+ LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return LDAP_BUSY;
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto dn2entry_retry;
default:
#ifdef NEW_LOGGING
- LDAP_LOG (( "referral", LDAP_LEVEL_ERR,
- "bdb_referrals: dn2entry failed: %s (%d)\n",
- db_strerror(rc), rc ));
+ LDAP_LOG ( OPERATION, ERR,
+ "bdb_referrals: dn2entry failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"bdb_referrals: dn2entry failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
#endif
if (e != NULL) {
- bdb_cache_return_entry_r(&bdb->bi_cache, e);
+ bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
}
if (matched != NULL) {
- bdb_cache_return_entry_r(&bdb->bi_cache, matched);
+ bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, matched, &lock);
}
send_ldap_result( conn, op, rc=LDAP_OTHER,
NULL, "internal error", NULL, NULL );
+ LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rc;
}
matched_dn = ch_strdup( matched->e_dn );
#ifdef NEW_LOGGING
- LDAP_LOG (( "referral", LDAP_LEVEL_DETAIL1,
+ LDAP_LOG ( OPERATION, DETAIL1,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
- (long) op->o_tag, dn->bv_val, matched_dn ));
+ (long) op->o_tag, dn->bv_val, matched_dn );
#else
Debug( LDAP_DEBUG_TRACE,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
refs = get_entry_referrals( be, conn, op, matched );
}
- bdb_cache_return_entry_r (&bdb->bi_cache, matched);
+ bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, matched, &lock);
matched = NULL;
} else if ( default_referral != NULL ) {
rc = LDAP_OTHER;
NULL, NULL );
}
+ LOCK_ID_FREE ( bdb->bi_dbenv, locker );
free( matched_dn );
return rc;
}
refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT );
#ifdef NEW_LOGGING
- LDAP_LOG (( "referral", LDAP_LEVEL_DETAIL1,
+ LDAP_LOG ( OPERATION, DETAIL1,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
- (long) op->o_tag, dn->bv_val, e->e_dn ));
+ (long) op->o_tag, dn->bv_val, e->e_dn );
#else
Debug( LDAP_DEBUG_TRACE,
"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
ber_bvarray_free( refs );
}
- bdb_cache_return_entry_r(&bdb->bi_cache, e);
+ bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+ LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rc;
}