+ fprintf( fp, "time: %ld\n", now );
+ fprintf( fp, "dn: %s\n", dn->bv_val );
+
+ replog1( NULL, op, change, fp, NULL );
+
+ if ( subsets > 0 ) {
+ void *first;
+ for ( i = subsets - 1; be->be_replica != NULL && be->be_replica[i] != NULL; i++ ) {
+
+ /* If no attrs, we already did this above */
+ if ( be->be_replica[i]->ri_attrs == NULL ) {
+ continue;
+ }
+
+ /* check if dn's suffix matches legal suffixes, if any */
+ if ( be->be_replica[i]->ri_nsuffix != NULL ) {
+ int j;
+
+ for ( j = 0; be->be_replica[i]->ri_nsuffix[j].bv_val; j++ ) {
+ if ( dnIsSuffix( ndn, &be->be_replica[i]->ri_nsuffix[j] ) ) {
+ break;
+ }
+ }
+
+ if ( !be->be_replica[i]->ri_nsuffix[j].bv_val ) {
+ /* do not add "replica:" line */
+ continue;
+ }
+ }
+ subsets = 0;
+ first = NULL;
+ switch( op->o_tag ) {
+ case LDAP_REQ_EXTENDED:
+ /* quick hack for extended operations */
+ /* assume change parameter is a Modfications* */
+ /* fall thru */
+ case LDAP_REQ_MODIFY:
+ for ( ml = change; ml != NULL; ml = ml->sml_next ) {
+ int is_in, exclude;
+
+ is_in = ad_inlist( ml->sml_desc, be->be_replica[i]->ri_attrs );
+ exclude = be->be_replica[i]->ri_exclude;
+
+ /*
+ * there might be a more clever way to do this test,
+ * but this way, at least, is comprehensible :)
+ */
+ if ( ( is_in && !exclude ) || ( !is_in && exclude ) ) {
+ subsets = 1;
+ first = ml;
+ break;
+ }
+ }
+ if ( !subsets ) {
+ continue;
+ }
+ break;
+ case LDAP_REQ_ADD:
+ e = change;
+ for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+ int is_in, exclude;
+
+ is_in = ad_inlist( a->a_desc, be->be_replica[i]->ri_attrs );
+ exclude = be->be_replica[i]->ri_exclude;
+
+ if ( ( is_in && !exclude ) || ( !is_in && exclude ) ) {
+ subsets = 1;
+ first = a;
+ break;
+ }
+ }
+ if ( !subsets ) {
+ continue;
+ }
+ break;
+ default:
+ /* Other operations were logged in the first pass */
+ continue;
+ }
+ fprintf( fp, "replica: %s\n", be->be_replica[i]->ri_host );
+ fprintf( fp, "time: %ld\n", now );
+ fprintf( fp, "dn: %s\n", dn->bv_val );
+ replog1( be->be_replica[i], op, change, fp, first );
+ }
+ }
+
+ lock_fclose( fp, lfp );
+ ldap_pvt_thread_mutex_unlock( &replog_mutex );
+}
+
+
+static void
+replog1(
+ struct slap_replica_info *ri,
+ Operation *op,
+ void *change,
+ FILE *fp,
+ void *first
+)
+{
+ Modifications *ml;
+ Attribute *a;
+ Entry *e;
+ struct slap_replog_moddn *moddn;