]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/delete.c
ITS#3796 fix IDL cache lock setup/teardown
[openldap] / servers / slapd / delete.c
index 1cd435201da82acc5c82ad1264a27c63c626d6d3..40a87c07f3bd67e051c54c9d1c1290d30e036849 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,6 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "ldap_pvt.h"
 #include "slap.h"
 
 #include "lutil.h"
@@ -46,12 +45,7 @@ do_delete(
 {
        struct berval dn = BER_BVNULL;
 
-#ifdef NEW_LOGGING
-       LDAP_LOG( OPERATION, ENTRY, 
-               "do_delete: conn %d\n", op->o_connid, 0, 0 );
-#else
        Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
-#endif
 
        /*
         * Parse the delete request.  It looks like this:
@@ -60,69 +54,42 @@ do_delete(
         */
 
        if ( ber_scanf( op->o_ber, "m", &dn ) == LBER_ERROR ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, ERR, 
-                       "do_delete: conn: %d  ber_scanf failed\n", op->o_connid, 0, 0 );
-#else
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
-#endif
                send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
                return SLAPD_DISCONNECT;
        }
 
        if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, ERR, 
-                       "do_delete: conn %d  get_ctrls failed\n", op->o_connid, 0, 0 );
-#else
                Debug( LDAP_DEBUG_ANY, "do_delete: get_ctrls failed\n", 0, 0, 0 );
-#endif
                goto cleanup;
        } 
 
        rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
                op->o_tmpmemctx );
        if( rs->sr_err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, 
-                       "do_delete: conn %d  invalid dn (%s)\n",
-                       op->o_connid, dn.bv_val, 0 );
-#else
                Debug( LDAP_DEBUG_ANY,
                        "do_delete: invalid dn (%s)\n", dn.bv_val, 0, 0 );
-#endif
                send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
                goto cleanup;
        }
 
        if( op->o_req_ndn.bv_len == 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, 
-                       "do_delete: conn %d: Attempt to delete root DSE.\n", 
-                       op->o_connid, 0, 0 );
-#else
                Debug( LDAP_DEBUG_ANY, "do_delete: root dse!\n", 0, 0, 0 );
-#endif
                /* protocolError would likely be a more appropriate error */
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                        "cannot delete the root DSE" );
                goto cleanup;
 
        } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, "do_delete: conn %d: "
-                       "Attempt to delete subschema subentry.\n", op->o_connid, 0, 0 );
-#else
                Debug( LDAP_DEBUG_ANY, "do_delete: subschema subentry!\n", 0, 0, 0 );
-#endif
                /* protocolError would likely be a more appropriate error */
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                        "cannot delete the root DSE" );
                goto cleanup;
        }
 
-       Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu DEL dn=\"%s\"\n",
-               op->o_connid, op->o_opid, op->o_req_dn.bv_val, 0, 0 );
+       Statslog( LDAP_DEBUG_STATS, "%s DEL dn=\"%s\"\n",
+               op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 );
 
        op->o_bd = frontendDB;
        rs->sr_err = frontendDB->be_delete( op, rs );
@@ -140,6 +107,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
 {
        struct berval   pdn = BER_BVNULL;
        int             manageDSAit;
+       BackendDB *op_be;
        
        manageDSAit = get_manageDSAit( op );
 
@@ -148,7 +116,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
+       op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
        if ( op->o_bd == NULL ) {
                rs->sr_ref = referral_rewrite( default_referral,
                        NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
@@ -157,16 +125,26 @@ fe_op_delete( Operation *op, SlapReply *rs )
                if ( rs->sr_ref != NULL ) {
                        rs->sr_err = LDAP_REFERRAL;
 
+                       op->o_bd = frontendDB;
                        send_ldap_result( op, rs );
+                       op->o_bd = NULL;
 
                        if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
                } else {
+                       op->o_bd = frontendDB;
                        send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                "no global superior knowledge" );
+                       op->o_bd = NULL;
                }
                goto cleanup;
        }
 
+       /* If we've got a glued backend, check the real backend */
+       op_be = op->o_bd;
+       if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
+               op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
+       }
+
        /* check restrictions */
        if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
@@ -192,13 +170,8 @@ fe_op_delete( Operation *op, SlapReply *rs )
                         * A preoperation plugin failure will abort the
                         * entire operation.
                         */
-#ifdef NEW_LOGGING
-                       LDAP_LOG( OPERATION, INFO, "do_delete: "
-                               "delete preoperation plugin failed\n", 0, 0, 0 );
-#else
                        Debug (LDAP_DEBUG_TRACE, "do_delete: "
                                "delete preoperation plugin failed.\n", 0, 0, 0);
-#endif
                        if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE,
                                (void *)&rs->sr_err ) != 0 ) ||
                                rs->sr_err == LDAP_SUCCESS )
@@ -230,6 +203,8 @@ fe_op_delete( Operation *op, SlapReply *rs )
                        int             org_managedsait;
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
 
+                       op->o_bd = op_be;
+
                        if ( !repl_user ) {
                                struct berval csn = BER_BVNULL;
                                char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
@@ -253,7 +228,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
                        org_managedsait = get_manageDSAit( op );
                        op->o_dn = op->o_bd->be_rootdn;
                        op->o_ndn = op->o_bd->be_rootndn;
-                       op->o_managedsait = 1;
+                       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 
                        while ( rs->sr_err == LDAP_SUCCESS &&
                                op->o_delete_glue_parent )
@@ -310,15 +285,9 @@ fe_op_delete( Operation *op, SlapReply *rs )
        if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
                SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0)
        {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO,
-                       "do_delete: delete postoperation plugins failed\n",
-                       0, 0, 0 );
-#else
                Debug(LDAP_DEBUG_TRACE,
                        "do_delete: delete postoperation plugins failed\n",
                        0, 0, 0 );
-#endif
        }
 #endif /* defined( LDAP_SLAPI ) */