]> git.sur5r.net Git - openldap/commitdiff
Make sure DB result codes are returned to caller; add missing retries to
authorHoward Chu <hyc@openldap.org>
Sat, 10 Jul 2004 19:06:20 +0000 (19:06 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 10 Jul 2004 19:06:20 +0000 (19:06 +0000)
callers of bdb_cache_find_id().

servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/search.c

index 484efe3094a7f8fc382ec99a61922c29e391a5af..5fa9a20ab6cd6c9489ad0b85063e556bc8924370 100644 (file)
@@ -692,9 +692,11 @@ load1:             if ( !(*eip)->bei_e && !((*eip)->bei_state & CACHE_ENTRY_LOADING)) {
                                        /* Give up original read lock, obtain write lock with
                                         * (possibly) new locker ID.
                                         */
-                                       bdb_cache_entry_db_relock( bdb->bi_dbenv, locker2,
-                                               *eip, 1, 0, lock );
-                                       if (!ep) {
+                                   if ( rc == 0 ) {
+                                               rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker2,
+                                                       *eip, 1, 0, lock );
+                                       }
+                                       if ( rc == 0 && !ep) {
                                                rc = bdb_id2entry( op->o_bd, ltid, id, &ep );
                                        }
                                        if ( rc == 0 ) {
@@ -708,7 +710,7 @@ load1:              if ( !(*eip)->bei_e && !((*eip)->bei_state & CACHE_ENTRY_LOADING)) {
                                        (*eip)->bei_state ^= CACHE_ENTRY_LOADING;
                                        if ( rc == 0 ) {
                                                /* If we succeeded, downgrade back to a readlock. */
-                                               bdb_cache_entry_db_relock( bdb->bi_dbenv, locker,
+                                               rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker,
                                                        *eip, 0, 0, lock );
                                        } else {
                                                /* Otherwise, release the lock. */
index 75ab32b2d49812dbfa5404c1acba6939232b304d..a63a4bae9985462a57387cc4cd85a5138bd35fc8 100644 (file)
@@ -215,9 +215,12 @@ static int search_aliases(
                        ida = bdb_idl_next(curscop, &cursora))
                {
                        ei = NULL;
+retry1:
                        rs->sr_err = bdb_cache_find_id(op, NULL,
                                ida, &ei, 0, locker, &lockr );
                        if (rs->sr_err != LDAP_SUCCESS) {
+                               if ( rs->sr_err == DB_LOCK_DEADLOCK ||
+                                       rs->sr_err == DB_LOCK_NOTGRANTED ) goto retry1;
                                continue;
                        }
                        a = ei->bei_e;
@@ -281,9 +284,15 @@ nextido:
                 * Set the name so that the scope's IDL can be retrieved.
                 */
                ei = NULL;
+sameido:
                rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
                        0, locker, &locka );
-               if ( rs->sr_err != LDAP_SUCCESS ) goto nextido;
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       if ( rs->sr_err == DB_LOCK_DEADLOCK ||
+                               rs->sr_err == DB_LOCK_NOTGRANTED )
+                               goto sameido;
+                       goto nextido;
+               }
                e = ei->bei_e;
        }
        return rs->sr_err;