/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Copyright 1998-2004 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 );
-
-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 );
-}
+replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now);
void
replog( Operation *op )
int count = 0;
#endif
int subsets = 0;
+ long now = slap_get_time();
+ char *replogfile;
- if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) {
+ replogfile = op->o_bd->be_replogfile ? op->o_bd->be_replogfile :
+ frontendDB->be_replogfile;
+ if ( !replogfile ) {
return;
}
ldap_pvt_thread_mutex_lock( &replog_mutex );
- if ( (fp = lock_fopen( op->o_bd->be_replogfile ? op->o_bd->be_replogfile :
- replogfile, "a", &lfp )) == NULL ) {
+ if ( (fp = lock_fopen( replogfile, "a", &lfp )) == NULL ) {
ldap_pvt_thread_mutex_unlock( &replog_mutex );
return;
}
}
#endif
- replog1( NULL, op, fp );
+ replog1( NULL, op, fp, now );
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 );
+ replog1( op->o_bd->be_replica[i], op, fp, now );
}
}
rephdr(
struct slap_replica_info *ri,
Operation *op,
- FILE *fp
+ FILE *fp,
+ long now
)
{
if ( ri ) {
fprintf( fp, "replica: %s\n", ri->ri_host );
}
- fprintf( fp, "time: %ld.%ld\n", op->o_time, op->o_tseq );
+ fprintf( fp, "time: %ld\n", now );
fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val );
}
replog1(
struct slap_replica_info *ri,
Operation *op,
- FILE *fp
+ FILE *fp,
+ long now
)
{
Modifications *ml;
* in any subset, otherwise drop it.
*/
if ( ocs && ml->sml_desc == slap_schema.si_ad_objectClass
- && ml->sml_bvalues ) {
+ && ml->sml_values )
+ {
int i, first = 1;
if ( ocs == -1 ) ocs = 0;
- for ( i=0; ml->sml_bvalues[i].bv_val; i++ ) {
+ for ( i=0; ml->sml_values[i].bv_val; i++ ) {
int match = 0;
for ( an = ri->ri_attrs; an->an_name.bv_val; an++ ) {
if ( an->an_oc ) {
ocs = 1;
match |= an->an_oc_exclude;
- if ( ml->sml_bvalues[i].bv_len == an->an_name.bv_len
- && !strcasecmp(ml->sml_bvalues[i].bv_val,
+ if ( ml->sml_values[i].bv_len == an->an_name.bv_len
+ && !strcasecmp(ml->sml_values[i].bv_val,
an->an_name.bv_val ) ) {
match = !an->an_oc_exclude;
break;
/* Found a match, log it */
if ( match ) {
if ( dohdr ) {
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
fprintf( fp, "changetype: modify\n" );
dohdr = 0;
}
}
}
if ( dohdr ) {
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
fprintf( fp, "changetype: modify\n" );
dohdr = 0;
}
fprintf( fp, "%s: %s\n", did, type );
- if ( ml->sml_bvalues ) {
- print_vals( fp, &ml->sml_desc->ad_cname, ml->sml_bvalues );
+ if ( ml->sml_values ) {
+ print_vals( fp, &ml->sml_desc->ad_cname, ml->sml_values );
}
fprintf( fp, "-\n" );
}
match ^= ri->ri_exclude;
if ( match ) {
if ( dohdr ) {
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
fprintf( fp, "changetype: add\n" );
dohdr = 0;
}
}
}
if ( dohdr ) {
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
fprintf( fp, "changetype: add\n" );
dohdr = 0;
}
break;
case LDAP_REQ_DELETE:
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
fprintf( fp, "changetype: delete\n" );
break;
case LDAP_REQ_MODRDN:
- rephdr( ri, op, fp );
+ rephdr( ri, op, fp, now );
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 );