]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/key.c
Fix ITS#1991 - referrals with sarch base == target (wasn't sure at first,
[openldap] / servers / slapd / back-ldbm / key.c
index c8dc26e6903e189a28a956f2a14dc97604403fad..0ea188a473bdf1c6f3d185da46c0ffa41495683c 100644 (file)
@@ -1,7 +1,7 @@
 /* index.c - routines for dealing with attribute indexes */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -24,10 +24,15 @@ key_read(
        ID_BLOCK **idout
 )
 {
-       Datum           key;
+       Datum           key;
        ID_BLOCK                *idl;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG( INDEX, ENTRY, "key_read: enter\n", 0, 0, 0 );
+#else
        Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
+#endif
+
 
        ldbm_datum_init( key );
        key.dptr = k->bv_val;
@@ -35,8 +40,14 @@ key_read(
 
        idl = idl_fetch( be, db, key );
 
+#ifdef NEW_LOGGING
+       LDAP_LOG( INDEX, ENTRY, 
+                  "key_read: %ld candidates\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
+#else
        Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
               idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
+#endif
+
 
        *idout = idl;
        return LDAP_SUCCESS;
@@ -53,15 +64,22 @@ key_change(
 )
 {
        int     rc;
-       Datum   key;
+       Datum   key;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG( INDEX, ENTRY, "key_change: %s ID %lx\n",
+                  op == SLAP_INDEX_ADD_OP ? "Add" : "Delete", (long)id, 0 );
+#else
        Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
                op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );
+#endif
+
 
        ldbm_datum_init( key );
        key.dptr = k->bv_val;
        key.dsize = k->bv_len;
 
+       ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
        if (op == SLAP_INDEX_ADD_OP) {
            /* Add values */
            rc = idl_insert_key( be, db, key, id );
@@ -70,9 +88,15 @@ key_change(
            /* Delete values */
            rc = idl_delete_key( be, db, key, id );
        }
+       ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
 
 
+#ifdef NEW_LOGGING
+       LDAP_LOG( INDEX, ENTRY, "key_change: return %d\n", rc, 0, 0 );
+#else
        Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );
+#endif
+
 
        ldap_pvt_thread_yield();