]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/idl.c
Add debug if bdb_cache_entry_db_lock fails to get a lock
[openldap] / servers / slapd / back-bdb / idl.c
index 4c445dbc271ac7669fd4fe76ab398ae56bdcdfc8..28c9a725e6e499beb5333a4e55d5bc5005358275 100644 (file)
@@ -446,13 +446,31 @@ bdb_idl_insert_key(
                                }
                                if ( count >= BDB_IDL_DB_SIZE ) {
                                /* No room, convert to a range */
+                                       DBT key2 = *key;
+
+                                       key2.dlen = key2.ulen;
+                                       key2.flags |= DB_DBT_PARTIAL;
+
                                        lo = tmp;
                                        data.data = &hi;
-                                       rc = cursor->c_get( cursor, key, &data, DB_LAST );
-                                       if ( rc != 0 ) {
-                                               err = "c_get last";
+                                       rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_NODUP );
+                                       if ( rc != 0 && rc != DB_NOTFOUND ) {
+                                               err = "c_get next_nodup";
                                                goto fail;
                                        }
+                                       if ( rc == DB_NOTFOUND ) {
+                                               rc = cursor->c_get( cursor, key, &data, DB_LAST );
+                                               if ( rc != 0 ) {
+                                                       err = "c_get last";
+                                                       goto fail;
+                                               }
+                                       } else {
+                                               rc = cursor->c_get( cursor, key, &data, DB_PREV );
+                                               if ( rc != 0 ) {
+                                                       err = "c_get prev";
+                                                       goto fail;
+                                               }
+                                       }
                                        if ( id < lo )
                                                lo = id;
                                        else if ( id > hi )
@@ -996,8 +1014,11 @@ bdb_idl_union(
        }
 
        if ( BDB_IDL_IS_RANGE( a ) || BDB_IDL_IS_RANGE(b) ) {
-over:          a[1] = IDL_MIN( BDB_IDL_FIRST(a), BDB_IDL_FIRST(b) );
-               a[2] = IDL_MAX( BDB_IDL_LAST(a), BDB_IDL_LAST(b) );
+over:          ida = IDL_MIN( BDB_IDL_FIRST(a), BDB_IDL_FIRST(b) );
+               idb = IDL_MAX( BDB_IDL_LAST(a), BDB_IDL_LAST(b) );
+               a[0] = NOID;
+               a[1] = ida;
+               a[2] = idb;
                return 0;
        }
 
@@ -1010,7 +1031,6 @@ over:             a[1] = IDL_MIN( BDB_IDL_FIRST(a), BDB_IDL_FIRST(b) );
        while( ida != NOID || idb != NOID ) {
                if ( ida < idb ) {
                        if( ++cursorc > BDB_IDL_UM_MAX ) {
-                               a[0] = NOID;
                                goto over;
                        }
                        b[cursorc] = ida;