]> git.sur5r.net Git - openldap/commitdiff
ITS#2348 - revert previous patch, use patch from ITS
authorHoward Chu <hyc@openldap.org>
Wed, 12 Mar 2003 13:40:54 +0000 (13:40 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 12 Mar 2003 13:40:54 +0000 (13:40 +0000)
servers/slapd/back-ldbm/idl.c

index fcfeebcf18199b8d4c5429ee047ca54c586a7969..16c3e6da519b6b7decbdaee40696cf4a07d909cc 100644 (file)
@@ -553,19 +553,13 @@ idl_insert_key(
 
 #ifndef USE_INDIRECT_NIDS
        /* select the block to try inserting into *//* XXX linear search XXX */
-       for ( i = 0; !ID_BLOCK_NOID(idl, i) && id > ID_BLOCK_ID(idl, i); i++ )
+       for ( i = 0; !ID_BLOCK_NOID(idl, i) && id >= ID_BLOCK_ID(idl, i); i++ )
                ;       /* NULL */
 #else
        i = idl_find(idl, id);
-       if (ID_BLOCK_ID(idl, i) < id)
+       if (ID_BLOCK_ID(idl, i) <= id)
                i++;
 #endif
-       /* The ID already exists in the IDL, no insert needed */
-       if (ID_BLOCK_ID(idl, i) == id) {
-               idl_free( idl );
-               return 0;
-       }
-
        if ( i != 0 ) {
                i--;
                first = 0;
@@ -573,6 +567,11 @@ idl_insert_key(
                first = 1;
        }
 
+       /* At this point, the following condition must be true:
+        * ID_BLOCK_ID(idl, i) <= id && id < ID_BLOCK_ID(idl, i+1)
+        * except when i is the first or the last block.
+        */
+
        /* get the block */
        cont_alloc( &k2, &key );
        cont_id( &k2, ID_BLOCK_ID(idl, i) );