]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/id2entry.c
Removed unnecessary definition that is already in core.schema.
[openldap] / servers / slapd / back-ldbm / id2entry.c
index 1e38d31a225af0a7f78867343115e639f89cd97b..8c4d8b14095f1bcad2f5ce6989dfa0edc594b56a 100644 (file)
@@ -25,7 +25,7 @@ id2entry_add( Backend *be, Entry *e )
        ldbm_datum_init( key );
        ldbm_datum_init( data );
 
-       Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %lu, \"%s\" )\n", e->e_id,
+       Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %ld, \"%s\" )\n", e->e_id,
            e->e_dn, 0 );
 
        if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
@@ -64,7 +64,7 @@ id2entry_delete( Backend *be, Entry *e )
        Datum           key;
        int             rc;
 
-       Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %lu, \"%s\" )\n", e->e_id,
+       Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %ld, \"%s\" )\n", e->e_id,
            e->e_dn, 0 );
 
 #ifdef notdef
@@ -84,7 +84,7 @@ id2entry_delete( Backend *be, Entry *e )
        }
 
        if ( cache_delete_entry( &li->li_cache, e ) != 0 ) {
-               Debug(LDAP_DEBUG_ANY, "could not delete %lu (%s) from cache\n",
+               Debug(LDAP_DEBUG_ANY, "could not delete %ld (%s) from cache\n",
                    e->e_id, e->e_dn, 0 );
        }
 
@@ -145,7 +145,7 @@ id2entry_rw( Backend *be, ID id, int rw )
        ldbm_cache_close( be, db );
 
        if ( e == NULL ) {
-               Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld )  (failed)\n",
+               Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (failed)\n",
                        rw ? "w" : "r", id, 0 );
                return( NULL );
        }
@@ -158,9 +158,20 @@ id2entry_rw( Backend *be, ID id, int rw )
        }
 
        if( cache_add_entry_rw( &li->li_cache, e, rw ) != 0 ) {
+               entry_free( e );
+
+               /* XXX this is a kludge.
+                * maybe the entry got added underneath us
+                * There are many underlying race condtions in the cache/disk code.
+                */
+               if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
+                       Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) 0x%lx (cache)\n",
+                               rw ? "w" : "r", id, (unsigned long) e );
+                       return( e );
+               }
+
                Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (cache add failed)\n",
                        rw ? "w" : "r", id, 0 );
-               entry_free( e );
                return NULL;
        }