]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/modify.c
Merged in per cache entry reader/writer locks from OPENLDAP_DEVEL_THREAD
[openldap] / servers / slapd / back-ldbm / modify.c
index 84f6f109dc672ddb516efafd7d248a183303d37e..df9414673648bb609383319d89d8c3ae97c2dfee 100644 (file)
@@ -6,9 +6,9 @@
 #include <sys/socket.h>
 #include "slap.h"
 #include "back-ldbm.h"
+#include "proto-back-ldbm.h"
 
 extern int             global_schemacheck;
-extern Entry           *dn2entry();
 extern Attribute       *attr_find();
 
 static int     add_values();
@@ -30,7 +30,9 @@ ldbm_back_modify(
        int             i, err, modtype;
        LDAPMod         *mod;
 
-       if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
+       Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0);
+
+       if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
                send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched,
                    NULL );
                if ( matched != NULL ) {
@@ -38,12 +40,14 @@ ldbm_back_modify(
                }
                return( -1 );
        }
+
+       /* check for deleted */
+
        /* lock entry */
 
        if ( (err = acl_check_mods( be, conn, op, e, mods )) != LDAP_SUCCESS ) {
                send_ldap_result( conn, op, err, NULL, NULL );
-               cache_return_entry( &li->li_cache, e );
-               return( -1 );
+               goto error_return;
        }
 
        for ( mod = mods; mod != NULL; mod = mod->mod_next ) {
@@ -68,6 +72,13 @@ ldbm_back_modify(
                }
        }
 
+       /* check that the entry still obeys the schema */
+       if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
+               Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
+               send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL, NULL );
+               goto error_return;
+       }
+
        /* check for abandon */
        pthread_mutex_lock( &op->o_abandonmutex );
        if ( op->o_abandon ) {
@@ -76,13 +87,6 @@ ldbm_back_modify(
        }
        pthread_mutex_unlock( &op->o_abandonmutex );
 
-       /* check that the entry still obeys the schema */
-       if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
-               Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL, NULL );
-               goto error_return;
-       }
-
        /* modify indexes */
        if ( index_add_mods( be, mods, e->e_id ) != 0 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
@@ -104,14 +108,11 @@ ldbm_back_modify(
        }
 
        send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
-       cache_return_entry( &li->li_cache, e );
-
+       cache_return_entry_w( &li->li_cache, e );
        return( 0 );
 
 error_return:;
-       cache_delete_entry( &li->li_cache, e );
-       cache_return_entry( &li->li_cache, e );
-
+       cache_return_entry_w( &li->li_cache, e );
        return( -1 );
 }