/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2005-2014 The OpenLDAP Foundation.
+ * Copyright 2005-2017 The OpenLDAP Foundation.
* Portions copyright 2004-2005 Symas Corporation.
* All rights reserved.
*
agebv->bv_len = ptr - agebv->bv_val;
}
-static slap_callback nullsc = { NULL, NULL, NULL, NULL };
+static slap_callback nullsc;
#define PURGE_INCREMENT 100
OperationBuffer opbuf;
Operation *op;
SlapReply rs = {REP_RESULT};
- slap_callback cb = { NULL, log_old_lookup, NULL, NULL };
+ slap_callback cb = { NULL, log_old_lookup, NULL, NULL, NULL };
Filter f;
AttributeAssertion ava = ATTRIBUTEASSERTION_INIT;
purge_data pd = {0};
}
ch_free( pd.ndn[i].bv_val );
ch_free( pd.dn[i].bv_val );
+ ldap_pvt_thread_pool_pausecheck( &connection_pool );
}
ch_free( pd.ndn );
ch_free( pd.dn );
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];
slap_callback *cb;
/* These internal ops are not logged */
- if ( op->o_dont_replicate && op->orm_no_opattrs )
+ if ( op->o_dont_replicate )
return SLAP_CB_CONTINUE;
ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
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 );
}
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 ) {
{
i++;
}
+ if ( m->sml_next && m->sml_desc == m->sml_next->sml_desc ) {
+ i++;
+ }
}
vals = ch_malloc( (i+1) * sizeof( struct berval ));
i = 0;
*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 ) {
op2.o_req_ndn = e->e_nname;
op2.ora_e = e;
op2.o_callback = &nullsc;
+ op2.o_csn = op->o_csn;
+ /* contextCSN updates may still reach here */
+ op2.o_dont_replicate = op->o_dont_replicate;
if (( lo->mask & LOG_OP_WRITES ) && !BER_BVISEMPTY( &op->o_csn )) {
- slap_queue_csn( &op2, &op->o_csn );
- do_graduate = 1;
+ struct berval maxcsn;
+ char cbuf[LDAP_PVT_CSNSTR_BUFSIZE];
+ int foundit;
+ cbuf[0] = '\0';
+ maxcsn.bv_val = cbuf;
+ maxcsn.bv_len = sizeof(cbuf);
+ /* If there was a commit CSN on the main DB,
+ * we must propagate it to the log DB for its
+ * own syncprov. Otherwise, don't generate one.
+ */
+ slap_get_commit_csn( op, &maxcsn, &foundit );
+ if ( !BER_BVISEMPTY( &maxcsn ) ) {
+ slap_queue_csn( &op2, &op->o_csn );
+ } else {
+ attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN,
+ &op->o_csn, op->o_tmpmemctx );
+ }
}
op2.o_bd->be_add( &op2, &rs2 );
+ if ( rs2.sr_err != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_SYNC,
+ "accesslog_response: got result 0x%x adding log entry %s\n",
+ rs2.sr_err, op2.o_req_dn.bv_val, 0 );
+ }
if ( e == op2.ora_e ) entry_free( e );
e = NULL;
- if ( do_graduate ) {
- slap_graduate_commit_csn( &op2 );
- if ( op2.o_csn.bv_val )
- op->o_tmpfree( op2.o_csn.bv_val, op->o_tmpmemctx );
- }
done:
if ( lo->mask & LOG_OP_WRITES )
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 );
int doit = 0;
/* These internal ops are not logged */
- if ( op->o_dont_replicate && op->orm_no_opattrs )
+ if ( op->o_dont_replicate )
return SLAP_CB_CONTINUE;
logop = accesslog_op2logop( op );
}
if ( doit ) {
- slap_callback *cb = op->o_tmpalloc( sizeof( slap_callback ), op->o_tmpmemctx ), *cb2;
+ slap_callback *cb = op->o_tmpcalloc( 1, sizeof( slap_callback ), op->o_tmpmemctx ), *cb2;
cb->sc_cleanup = accesslog_mod_cleanup;
- cb->sc_response = NULL;
cb->sc_private = on;
- cb->sc_next = NULL;
for ( cb2 = op->o_callback; cb2->sc_next; cb2 = cb2->sc_next );
cb2->sc_next = 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 )))
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;