X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Fdelete.c;h=a7997e0f3f641bd4f2b913bf90f9700d90b03bef;hb=523fd2c891cfdbd318642b20a105adb4b2f9149c;hp=c773929ffb43a64eb73ba3e3b7c28124a5655b08;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index c773929ffb..a7997e0f3f 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -1,13 +1,16 @@ /* delete.c - ldbm backend delete routine */ +#include "portable.h" + #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "back-ldbm.h" +#include "proto-back-ldbm.h" -extern Entry *dn2entry(); extern Attribute *attr_find(); int @@ -22,7 +25,12 @@ ldbm_back_delete( char *matched = NULL; Entry *e; - if ( (e = dn2entry( be, dn, &matched )) == NULL ) { + Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_delete: %s\n", dn, 0, 0); + + /* get entry with writer lock */ + if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) { + Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n", + dn, 0, 0); send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" ); if ( matched != NULL ) { free( matched ); @@ -30,38 +38,63 @@ ldbm_back_delete( return( -1 ); } + Debug (LDAP_DEBUG_TRACE, + "rdwr_Xchk: readers_reading: %d writer_writing: %d\n", + e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); + + /* check for deleted */ + if ( has_children( be, e ) ) { + Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: non leaf %s\n", + dn, 0, 0); send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + goto error_return; } if ( ! access_allowed( be, conn, op, e, "entry", NULL, op->o_dn, ACL_WRITE ) ) { + Debug(LDAP_DEBUG_ARGS, + "<=- ldbm_back_delete: insufficient access %s\n", + dn, 0, 0); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + goto error_return; } + Debug (LDAP_DEBUG_TRACE, + "rdwr_Xchk: readers_reading: %d writer_writing: %d\n", + e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); + /* XXX delete from parent's id2children entry XXX */ /* delete from dn2id mapping */ if ( dn2id_delete( be, e->e_dn ) != 0 ) { + Debug(LDAP_DEBUG_ARGS, + "<=- ldbm_back_delete: operations error %s\n", + dn, 0, 0); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + goto error_return; } /* delete from disk and cache */ if ( id2entry_delete( be, e ) != 0 ) { + Debug(LDAP_DEBUG_ARGS, + "<=- ldbm_back_delete: operations error %s\n", + dn, 0, 0); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); - cache_return_entry( &li->li_cache, e ); - return( -1 ); + goto error_return; } - cache_return_entry( &li->li_cache, e ); + + /* free entry and writer lock */ + cache_return_entry_w( &li->li_cache, e ); send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); return( 0 ); + +error_return:; + /* free entry and writer lock */ + cache_return_entry_w( &li->li_cache, e ); + + return( -1 ); }