return ( be->be_replica[nr]->ri_attrs == NULL );
}
+static struct timestamp {
+ long time;
+ long seq;
+} oldstamp;
+
static void
print_vals( FILE *fp, struct berval *type, struct berval *bv );
static void
-replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now);
+replog1( struct slap_replica_info *ri, Operation *op, FILE *fp );
+
+void
+repstamp( Operation *op )
+{
+ ldap_pvt_thread_mutex_lock( &replog_mutex );
+ op->o_time = slap_get_time();
+ if ( op->o_time == oldstamp.time ) {
+ op->o_tseq = ++oldstamp.seq;
+ } else {
+ oldstamp.time = op->o_time;
+ oldstamp.seq = 0;
+ op->o_tseq = 0;
+ }
+ ldap_pvt_thread_mutex_unlock( &replog_mutex );
+}
void
replog( Operation *op )
int count = 0;
#endif
int subsets = 0;
- long now = slap_get_time();
if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) {
return;
}
#endif
- replog1( NULL, op, fp, now );
+ replog1( NULL, op, fp );
if ( subsets > 0 ) {
for ( i = subsets - 1; op->o_bd->be_replica[i] != NULL; i++ ) {
/* Other operations were logged in the first pass */
continue;
}
- replog1( op->o_bd->be_replica[i], op, fp, now );
+ replog1( op->o_bd->be_replica[i], op, fp );
}
}
rephdr(
struct slap_replica_info *ri,
Operation *op,
- FILE *fp,
- long now
+ FILE *fp
)
{
if ( ri ) {
fprintf( fp, "replica: %s\n", ri->ri_host );
}
- fprintf( fp, "time: %ld\n", now );
+ fprintf( fp, "time: %ld.%ld\n", op->o_time, op->o_tseq );
fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val );
}
replog1(
struct slap_replica_info *ri,
Operation *op,
- FILE *fp,
- long now
+ FILE *fp
)
{
Modifications *ml;
/* Found a match, log it */
if ( match ) {
if ( dohdr ) {
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: modify\n" );
dohdr = 0;
}
}
}
if ( dohdr ) {
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: modify\n" );
dohdr = 0;
}
match ^= ri->ri_exclude;
if ( match ) {
if ( dohdr ) {
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: add\n" );
dohdr = 0;
}
}
}
if ( dohdr ) {
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: add\n" );
dohdr = 0;
}
break;
case LDAP_REQ_DELETE:
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: delete\n" );
break;
case LDAP_REQ_MODRDN:
- rephdr( ri, op, fp, now );
+ rephdr( ri, op, fp );
fprintf( fp, "changetype: modrdn\n" );
fprintf( fp, "newrdn: %s\n", op->orr_newrdn.bv_val );
fprintf( fp, "deleteoldrdn: %d\n", op->orr_deleteoldrdn ? 1 : 0 );
if ( op->o_bd->be_delete ) {
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
+ if ( log_change ) repstamp( op );
if ( (*op->o_bd->be_delete)( op, &rs ) == 0 ) {
if ( log_change ) {
replog( op );
if ( op->o_bd->be_add ) {
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
+ if ( log_changes ) repstamp( op );
if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) {
if ( log_changes ) {
replog( op );
if ( op->o_bd->be_modrdn ) {
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
+ if ( log_change ) repstamp( op );
if ( (*op->o_bd->be_modrdn)( op, &rs ) == 0 ) {
if ( log_change ) {
replog( op );
goto cleanup;
}
}
+ if ( log_change ) repstamp( op );
if ( (*op->o_bd->be_modify)( op, &rs ) == 0 ) {
if ( log_change ) {
replog( op );