]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/accesslog.c
ITS#8801 Fix CSN queue processing
[openldap] / servers / slapd / overlays / accesslog.c
index fb5d88989a0ada7b63391f7172a172a7d5945256..6b9c729c5ed363167d8bed3dab0cc1a6e58fdcfc 100644 (file)
@@ -1458,7 +1458,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
        Modifications *m;
        struct berval *b, uuid = BER_BVNULL;
        int i;
-       int logop, do_graduate = 0;
+       int logop;
        slap_verbmasks *lo;
        Entry *e = NULL, *old = NULL, *e_uuid = NULL;
        char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE+8];
@@ -1515,6 +1515,11 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
                                break;
                        }
                }
+#ifdef RMUTEX_DEBUG
+               Debug( LDAP_DEBUG_SYNC,
+                       "accesslog_response: unlocking rmutex for tid %x\n",
+                       op->o_tid, 0, 0 );
+#endif
                ldap_pvt_thread_rmutex_unlock( &li->li_op_rmutex, op->o_tid );
        }
 
@@ -1586,7 +1591,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
 
        case LOG_EN_MODRDN:
        case LOG_EN_MODIFY:
-               /* count all the mods */
+               /* count all the mods + attributes (ITS#6545) */
                i = 0;
                for ( m = op->orm_modlist; m; m = m->sml_next ) {
                        if ( m->sml_values ) {
@@ -1596,6 +1601,9 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
                        {
                                i++;
                        }
+                       if ( m->sml_next && m->sml_desc == m->sml_next->sml_desc ) {
+                               i++;
+                       }
                }
                vals = ch_malloc( (i+1) * sizeof( struct berval ));
                i = 0;
@@ -1666,6 +1674,12 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
                                *ptr = '\0';
                                i++;
                        }
+                       /* ITS#6545: when the same attribute is edited multiple times,
+                        * record the transition */
+                       if ( m->sml_next && m->sml_desc == m->sml_next->sml_desc ) {
+                               ber_str2bv( ":", STRLENOF(":"), 1, &vals[i] );
+                               i++;
+                       }
                }
 
                if ( i > 0 ) {
@@ -1858,7 +1872,6 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
                slap_get_commit_csn( op, &maxcsn, &foundit );
                if ( !BER_BVISEMPTY( &maxcsn ) ) {
                        slap_queue_csn( &op2, &op->o_csn );
-                       do_graduate = 1;
                } else {
                        attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN,
                                &op->o_csn, op->o_tmpmemctx );
@@ -1868,9 +1881,6 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
        op2.o_bd->be_add( &op2, &rs2 );
        if ( e == op2.ora_e ) entry_free( e );
        e = NULL;
-       if ( do_graduate ) {
-               slap_graduate_commit_csn( &op2 );
-       }
 
 done:
        if ( lo->mask & LOG_OP_WRITES )
@@ -1929,7 +1939,7 @@ accesslog_mod_cleanup( Operation *op, SlapReply *rs )
 
        op->o_tmpfree( sc, op->o_tmpmemctx );
 
-       if ( on ) {
+       if ( on && rs->sr_err != LDAP_SUCCESS ) {
                BackendInfo *bi = op->o_bd->bd_info;
                op->o_bd->bd_info = (BackendInfo *)on;
                accesslog_response( op, rs );
@@ -1980,13 +1990,23 @@ accesslog_op_mod( Operation *op, SlapReply *rs )
        }
                        
        if ( doit ) {
-               slap_callback *cb = op->o_tmpcalloc( 1, sizeof( slap_callback ), op->o_tmpmemctx ), *cb2;
+               slap_callback *cb = op->o_tmpcalloc( 1, sizeof( slap_callback ), op->o_tmpmemctx );
                cb->sc_cleanup = accesslog_mod_cleanup;
                cb->sc_private = on;
-               for ( cb2 = op->o_callback; cb2->sc_next; cb2 = cb2->sc_next );
-               cb2->sc_next = cb;
+               cb->sc_next = op->o_callback;
+               op->o_callback = cb;
 
+#ifdef RMUTEX_DEBUG
+               Debug( LDAP_DEBUG_SYNC,
+                       "accesslog_op_mod: locking rmutex for tid %x\n",
+                       op->o_tid, 0, 0 );
+#endif
                ldap_pvt_thread_rmutex_lock( &li->li_op_rmutex, op->o_tid );
+#ifdef RMUTEX_DEBUG
+               Debug( LDAP_DEBUG_STATS,
+                       "accesslog_op_mod: locked rmutex for tid %x\n",
+                       op->o_tid, 0, 0 );
+#endif
                if ( li->li_oldf && ( op->o_tag == LDAP_REQ_DELETE ||
                        op->o_tag == LDAP_REQ_MODIFY ||
                        ( op->o_tag == LDAP_REQ_MODRDN && li->li_oldattrs )))
@@ -2274,6 +2294,7 @@ accesslog_db_root(
                db = *li->li_db;
                op->o_bd = &db;
 
+               op->o_tag = LDAP_REQ_ADD;
                op->ora_e = e;
                op->o_req_dn = e->e_name;
                op->o_req_ndn = e->e_nname;