]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/modify.c
log the right function names
[openldap] / servers / slapd / back-bdb / modify.c
index 45d2efeb11eb9516fd8a87b3a5f4db93d7d5949f..a50bbea983b57b15b9d422e186f96b8f76b607ba 100644 (file)
@@ -21,7 +21,6 @@
 #include <ac/time.h>
 
 #include "back-bdb.h"
-#include "external.h"
 
 static struct berval scbva[] = {
        BER_BVC("glue"),
@@ -44,13 +43,8 @@ int bdb_modify_internal(
        Attribute       *ap;
        int                     glue_attr_delete = 0;
 
-#ifdef NEW_LOGGING
-       LDAP_LOG ( OPERATION, ENTRY, "bdb_modify_internal: 0x%08lx: %s\n", 
-               e->e_id, e->e_dn, 0 );
-#else
        Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n",
                e->e_id, e->e_dn, 0);
-#endif
 
        if ( !acl_check_modlist( op, e, modlist )) {
                return LDAP_INSUFFICIENT_ACCESS;
@@ -97,21 +91,12 @@ int bdb_modify_internal(
 
                switch ( mod->sm_op ) {
                case LDAP_MOD_ADD:
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify_internal: add\n", 0,0,0);
-#else
                        Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: add\n", 0, 0, 0);
-#endif
                        err = modify_add_values( e, mod, get_permissiveModify(op),
                                text, textbuf, textlen );
                        if( err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                                Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
                                        err, *text, 0);
-#endif
                        }
                        break;
 
@@ -121,75 +106,40 @@ int bdb_modify_internal(
                                break;
                        }
 
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1, 
-                               "bdb_modify_internal: delete\n", 0, 0, 0 );
-#else
                        Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: delete\n", 0, 0, 0);
-#endif
                        err = modify_delete_values( e, mod, get_permissiveModify(op),
                                text, textbuf, textlen );
                        assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
                        if( err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                                Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
                                        err, *text, 0);
-#endif
                        }
                        break;
 
                case LDAP_MOD_REPLACE:
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1, 
-                               "bdb_modify_internal: replace\n", 0, 0, 0 );
-#else
                        Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: replace\n", 0, 0, 0);
-#endif
                        err = modify_replace_values( e, mod, get_permissiveModify(op),
                                text, textbuf, textlen );
                        if( err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                                Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
                                        err, *text, 0);
-#endif
                        }
                        break;
 
                case LDAP_MOD_INCREMENT:
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1, 
-                               "bdb_modify_internal: increment\n", 0, 0, 0 );
-#else
                        Debug(LDAP_DEBUG_ARGS,
                                "bdb_modify_internal: increment\n", 0, 0, 0);
-#endif
                        err = modify_increment_values( e, mod, get_permissiveModify(op),
                                text, textbuf, textlen );
                        if( err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                                Debug(LDAP_DEBUG_ARGS,
                                        "bdb_modify_internal: %d %s\n",
                                        err, *text, 0);
-#endif
                        }
                        break;
 
                case SLAP_MOD_SOFTADD:
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1, 
-                               "bdb_modify_internal: softadd\n",0,0,0 );
-#else
                        Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: softadd\n", 0, 0, 0);
-#endif
                        /* Avoid problems in index_add_mods()
                         * We need to add index if necessary.
                         */
@@ -205,33 +155,18 @@ int bdb_modify_internal(
                        }
 
                        if( err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                                Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
                                        err, *text, 0);
-#endif
                        }
                        break;
 
                default:
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: invalid op %d\n", mod->sm_op, 0, 0 );
-#else
                        Debug(LDAP_DEBUG_ANY, "bdb_modify_internal: invalid op %d\n",
                                mod->sm_op, 0, 0);
-#endif
                        *text = "Invalid modify operation";
                        err = LDAP_OTHER;
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: %d %s\n", err, *text, 0 );
-#else
                        Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
                                err, *text, 0);
-#endif
                }
 
                if ( err != LDAP_SUCCESS ) {
@@ -273,15 +208,9 @@ int bdb_modify_internal(
                e->e_attrs = save_attrs;
 
                if ( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, ERR, "bdb_modify_internal: "
-                               "entry failed schema check %s\n", 
-                               *text, 0, 0 );
-#else
                        Debug( LDAP_DEBUG_ANY,
                                "entry failed schema check: %s\n",
                                *text, 0, 0 );
-#endif
                }
 
                /* if NOOP then silently revert to saved attrs */
@@ -299,15 +228,9 @@ int bdb_modify_internal(
                        if ( rc != LDAP_SUCCESS ) {
                                attrs_free( e->e_attrs );
                                e->e_attrs = save_attrs;
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: attribute index delete failure\n",
-                                       0, 0, 0 );
-#else
                                Debug( LDAP_DEBUG_ANY,
                                       "Attribute index delete failure",
                                       0, 0, 0 );
-#endif
                                return rc;
                        }
                        ap->a_flags &= ~SLAP_ATTR_IXDEL;
@@ -323,15 +246,9 @@ int bdb_modify_internal(
                        if ( rc != LDAP_SUCCESS ) {
                                attrs_free( e->e_attrs );
                                e->e_attrs = save_attrs;
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR, 
-                                       "bdb_modify_internal: attribute index add failure\n", 
-                                       0, 0, 0 );
-#else
                                Debug( LDAP_DEBUG_ANY,
                                       "Attribute index add failure",
                                       0, 0, 0 );
-#endif
                                return rc;
                        }
                        ap->a_flags &= ~SLAP_ATTR_IXADD;
@@ -372,13 +289,8 @@ bdb_modify( Operation *op, SlapReply *rs )
        Entry           *ctxcsn_e;
        int                     ctxcsn_added = 0;
 
-#ifdef NEW_LOGGING
-       LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n",
-               op->o_req_dn.bv_val, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n",
+       Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(bdb_modify) ": %s\n",
                op->o_req_dn.bv_val, 0, 0 );
-#endif
 
        ctrls[num_ctrls] = NULL;
 
@@ -392,12 +304,8 @@ retry:     /* transaction retry */
                        bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
                        e = NULL;
                }
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify: retrying...\n", 0, 0, 0 );
-#else
                Debug(LDAP_DEBUG_TRACE,
-                       "bdb_modify: retrying...\n", 0, 0, 0);
-#endif
+                       LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0);
 
                pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
                while ( pm_list != NULL ) {
@@ -425,14 +333,9 @@ retry:     /* transaction retry */
                bdb->bi_db_opflags );
        rs->sr_text = NULL;
        if( rs->sr_err != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, 
-                       "bdb_modify: txn_begin failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: txn_begin failed: %s (%d)\n",
-                       db_strerror(rs->sr_err), rs->sr_err, 0 );
-#endif
+                       LDAP_XSTRING(bdb_modify) ": txn_begin failed: "
+                       "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "internal error";
                goto return_results;
@@ -452,14 +355,9 @@ retry:     /* transaction retry */
                locker, &lock );
 
        if ( rs->sr_err != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, 
-                       "bdb_modify: dn2entry failed: (%d)\n", rs->sr_err, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: dn2entry failed (%d)\n",
+                       LDAP_XSTRING(bdb_modify) ": dn2entry failed (%d)\n",
                        rs->sr_err, 0, 0 );
-#endif
                switch( rs->sr_err ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
@@ -482,6 +380,7 @@ retry:      /* transaction retry */
        if (( rs->sr_err == DB_NOTFOUND ) ||
                ( !manageDSAit && e && is_entry_glue( e )))
        {
+               BerVarray deref = NULL;
                if ( e != NULL ) {
                        rs->sr_matched = ch_strdup( e->e_dn );
                        rs->sr_ref = is_entry_referral( e )
@@ -491,7 +390,6 @@ retry:      /* transaction retry */
                        e = NULL;
 
                } else {
-                       BerVarray deref = NULL;
                        if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                syncinfo_t *si;
                                LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
@@ -503,7 +401,7 @@ retry:      /* transaction retry */
                                deref = default_referral;
                        }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                               LDAP_SCOPE_DEFAULT );
+                                       LDAP_SCOPE_DEFAULT );
                }
 
                rs->sr_err = LDAP_REFERRAL;
@@ -512,6 +410,9 @@ retry:      /* transaction retry */
                if ( rs->sr_ref != default_referral ) {
                        ber_bvarray_free( rs->sr_ref );
                }
+               if ( deref != default_referral ) {
+                       ber_bvarray_free( deref );
+               }
                free( (char *)rs->sr_matched );
                rs->sr_ref = NULL;
                rs->sr_matched = NULL;
@@ -523,15 +424,9 @@ retry:     /* transaction retry */
                /* entry is a referral, don't allow modify */
                rs->sr_ref = get_entry_referrals( op, e );
 
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1,
-                       "bdb_modify: entry is referral\n",
-                       0, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: entry is referral\n",
+                       LDAP_XSTRING(bdb_modify) ": entry is referral\n",
                        0, 0, 0 );
-#endif
 
                rs->sr_err = LDAP_REFERRAL;
                rs->sr_matched = e->e_name.bv_val;
@@ -554,16 +449,14 @@ retry:    /* transaction retry */
                ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
                LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
                        rc = bdb_psearch(op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY );
-                       if ( rc ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG ( OPERATION, ERR,
-                                       "bdb_modify: persistent search failed (%d,%d)\n",
-                                       rc, rs->sr_err, 0 );
-#else
+                       if ( rc == LDAP_BUSY && op->o_ps_send_wait ) {
+                               ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
+                               goto retry;
+                       } else if ( rc ) {
                                Debug( LDAP_DEBUG_TRACE,
-                                       "bdb_modify: persistent search failed (%d,%d)\n",
+                                       LDAP_XSTRING(bdb_modify)
+                                       ": persistent search failed (%d,%d)\n",
                                        rc, rs->sr_err, 0 );
-#endif
                        }
                }
                ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
@@ -577,13 +470,9 @@ retry:     /* transaction retry */
                if ( slap_read_controls( op, rs, e,
                        &slap_pre_read_bv, preread_ctrl ) )
                {
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1,
-                               "<=- bdb_modify: pre-read failed!\n", 0, 0, 0 );
-#else
                        Debug( LDAP_DEBUG_TRACE,
-                               "<=- bdb_modify: pre-read failed!\n", 0, 0, 0 );
-#endif
+                               "<=- " LDAP_XSTRING(bdb_modify)
+                               ": pre-read failed!\n", 0, 0, 0 );
                        goto return_results;
                }
        }
@@ -593,15 +482,10 @@ retry:    /* transaction retry */
                bdb->bi_db_opflags );
        rs->sr_text = NULL;
        if( rs->sr_err != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ERR, 
-                       "bdb_modify: txn_begin(2) failed: %s (%d)\n",
-                       db_strerror(rs->sr_err), rs->sr_err, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: txn_begin(2) failed: %s (%d)\n",
+                       LDAP_XSTRING(bdb_modify) ": txn_begin(2) failed: "
+                       "%s (%d)\n",
                        db_strerror(rs->sr_err), rs->sr_err, 0 );
-#endif
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "internal error";
                goto return_results;
@@ -612,14 +496,9 @@ retry:     /* transaction retry */
                &dummy, &rs->sr_text, textbuf, textlen );
 
        if( rs->sr_err != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ERR, 
-                       "bdb_modify: modify failed (%d)\n", rs->sr_err, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: modify failed (%d)\n",
+                       LDAP_XSTRING(bdb_modify) ": modify failed (%d)\n",
                        rs->sr_err, 0, 0 );
-#endif
                if ( (rs->sr_err == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) {
                        rs->sr_err = opinfo.boi_err;
                }
@@ -636,14 +515,9 @@ retry:     /* transaction retry */
        /* change the entry itself */
        rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy );
        if ( rs->sr_err != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ERR, 
-                       "bdb_modify: id2entry update failed (%d)\n", rs->sr_err, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: id2entry update failed (%d)\n",
-                       rs->sr_err, 0, 0 );
-#endif
+                       LDAP_XSTRING(bdb_modify) ": id2entry update failed "
+                       "(%d)\n", rs->sr_err, 0, 0 );
                switch( rs->sr_err ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
@@ -678,13 +552,9 @@ retry:     /* transaction retry */
                if( slap_read_controls( op, rs, &dummy,
                        &slap_post_read_bv, postread_ctrl ) )
                {
-#ifdef NEW_LOGGING
-                       LDAP_LOG ( OPERATION, DETAIL1,
-                               "<=- bdb_modify: post-read failed!\n", 0, 0, 0 );
-#else
                        Debug( LDAP_DEBUG_TRACE,
-                               "<=- bdb_modify: post-read failed!\n", 0, 0, 0 );
-#endif
+                               "<=- " LDAP_XSTRING(bdb_modify)
+                               ": post-read failed!\n", 0, 0, 0 );
                        goto return_results;
                }
        }
@@ -718,15 +588,11 @@ retry:    /* transaction retry */
                        LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
                                rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
                                if ( rc ) {
-#ifdef NEW_LOGGING
-                                       LDAP_LOG ( OPERATION, ERR,
-                                               "bdb_modify: persistent search failed (%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-#else
                                        Debug( LDAP_DEBUG_TRACE,
-                                               "bdb_modify: persistent search failed (%d,%d)\n",
+                                               LDAP_XSTRING(bdb_modify)
+                                               ": persistent search failed "
+                                               "(%d,%d)\n",
                                                rc, rs->sr_err, 0 );
-#endif
                                }
                        }
                        pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
@@ -734,15 +600,11 @@ retry:    /* transaction retry */
                                rc = bdb_psearch(op, rs, pm_list->ps_op,
                                                        e, LDAP_PSEARCH_BY_SCOPEOUT);
                                if ( rc ) {
-#ifdef NEW_LOGGING
-                                       LDAP_LOG ( OPERATION, ERR,
-                                               "bdb_modify: persistent search failed (%d,%d)\n",
-                                               rc, rs->sr_err, 0 );
-#else
                                        Debug( LDAP_DEBUG_TRACE,
-                                               "bdb_modify: persistent search failed (%d,%d)\n",
+                                               LDAP_XSTRING(bdb_modify)
+                                               ": persistent search failed "
+                                               "(%d,%d)\n",
                                                rc, rs->sr_err, 0 );
-#endif
                                }
                                LDAP_LIST_REMOVE ( pm_list, ps_link );
                                pm_prev = pm_list;
@@ -758,33 +620,20 @@ retry:    /* transaction retry */
        op->o_private = NULL;
 
        if( rs->sr_err != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ERR, 
-                       "bdb_modify: txn_%s failed %s (%d)\n", 
-                       op->o_noop ? "abort (no_op)" : "commit",
-                       db_strerror(rs->sr_err), rs->sr_err );
-#else
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: txn_%s failed: %s (%d)\n",
+                       LDAP_XSTRING(bdb_modify) ": txn_%s failed: %s (%d)\n",
                        op->o_noop ? "abort (no-op)" : "commit",
                        db_strerror(rs->sr_err), rs->sr_err );
-#endif
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "commit failed";
 
                goto return_results;
        }
 
-#ifdef NEW_LOGGING
-       LDAP_LOG ( OPERATION, DETAIL1, 
-               "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", 
-               op->o_noop ? " (no_op)" : "", e->e_id, e->e_dn );
-#else
        Debug( LDAP_DEBUG_TRACE,
-               "bdb_modify: updated%s id=%08lx dn=\"%s\"\n",
+               LDAP_XSTRING(bdb_modify) ": updated%s id=%08lx dn=\"%s\"\n",
                op->o_noop ? " (no-op)" : "",
-               e->e_id, e->e_dn );
-#endif
+               dummy.e_id, op->o_req_dn.bv_val );
 
        rs->sr_err = LDAP_SUCCESS;
        rs->sr_text = NULL;
@@ -820,12 +669,12 @@ done:
        }
 
        if( preread_ctrl != NULL ) {
-               slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
-               slap_sl_free( *preread_ctrl, &op->o_tmpmemctx );
+               slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
+               slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
        }
        if( postread_ctrl != NULL ) {
-               slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
-               slap_sl_free( *postread_ctrl, &op->o_tmpmemctx );
+               slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
+               slap_sl_free( *postread_ctrl, op->o_tmpmemctx );
        }
        return rs->sr_err;
 }