File slapo-syncprov-skip-its5709.dif of Package openldap2-client

Index: servers/slapd/proto-slap.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.762
retrieving revision 1.763
diff -u -r1.762 -r1.763
--- servers/slapd/proto-slap.h	1 Nov 2008 14:16:49 -0000	1.762
+++ servers/slapd/proto-slap.h	2 Nov 2008 21:16:20 -0000	1.763
@@ -804,7 +804,7 @@
 LDAP_SLAPD_V( const struct berval ) slap_ldapsync_bv;
 LDAP_SLAPD_V( const struct berval ) slap_ldapsync_cn_bv;
 LDAP_SLAPD_F (void) slap_get_commit_csn LDAP_P((
-	Operation *, struct berval *maxcsn ));
+	Operation *, struct berval *maxcsn, int *foundit ));
 LDAP_SLAPD_F (void) slap_rewind_commit_csn LDAP_P(( Operation * ));
 LDAP_SLAPD_F (void) slap_graduate_commit_csn LDAP_P(( Operation * ));
 LDAP_SLAPD_F (Entry *) slap_create_context_csn_entry LDAP_P(( Backend *, struct berval *));
Index: servers/slapd/overlays/syncprov.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/overlays/syncprov.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -r1.249 -r1.250
--- servers/slapd/overlays/syncprov.c	28 Oct 2008 19:33:46 -0000	1.249
+++ servers/slapd/overlays/syncprov.c	2 Nov 2008 14:26:25 -0000	1.250
@@ -1604,12 +1604,12 @@
 	{
 		struct berval maxcsn = BER_BVNULL;
 		char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
-		int do_check = 0, have_psearches;
+		int do_check = 0, have_psearches, foundit;
 
 		/* Update our context CSN */
 		cbuf[0] = '\0';
 		ldap_pvt_thread_rdwr_wlock( &si->si_csn_rwlock );
-		slap_get_commit_csn( op, &maxcsn );
+		slap_get_commit_csn( op, &maxcsn, &foundit );
 		if ( BER_BVISNULL( &maxcsn ) && SLAP_GLUE_SUBORDINATE( op->o_bd )) {
 			/* syncrepl queues the CSN values in the db where
 			 * it is configured , not where the changes are made.
@@ -1618,7 +1618,7 @@
 			 */
 			BackendDB *be = op->o_bd;
 			op->o_bd = select_backend( &be->be_nsuffix[0], 1);
-			slap_get_commit_csn( op, &maxcsn );
+			slap_get_commit_csn( op, &maxcsn, &foundit );
 			op->o_bd = be;
 		}
 		if ( !BER_BVISNULL( &maxcsn ) ) {
@@ -1641,7 +1641,7 @@
 					sizeof(int));
 				si->si_sids[i] = sid;
 			}
-		} else {
+		} else if ( !foundit ) {
 			/* internal ops that aren't meant to be replicated */
 			ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock );
 			return SLAP_CB_CONTINUE;
@@ -1678,8 +1678,11 @@
 			ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock );
 		}
 
-		opc->sctxcsn.bv_len = maxcsn.bv_len;
-		opc->sctxcsn.bv_val = cbuf;
+		/* only update consumer ctx if this is the greatest csn */
+		if ( bvmatch( &maxcsn, &op->o_csn )) {
+			opc->sctxcsn.bv_len = maxcsn.bv_len;
+			opc->sctxcsn.bv_val = cbuf;
+		}
 
 		/* Handle any persistent searches */
 		ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
Index: servers/slapd/ctxcsn.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/ctxcsn.c,v
retrieving revision 1.47
retrieving revision 1.50
diff -u -r1.47 -r1.50
--- servers/slapd/ctxcsn.c	10 Feb 2008 01:18:22 -0000	1.47
+++ servers/slapd/ctxcsn.c	2 Nov 2008 21:16:20 -0000	1.50
@@ -33,71 +33,72 @@
 void
 slap_get_commit_csn(
 	Operation *op,
-	struct berval *maxcsn
+	struct berval *maxcsn,
+	int *foundit
 )
 {
 	struct slap_csn_entry *csne, *committed_csne = NULL;
+	BackendDB *be = op->o_bd->bd_self;
 
 	if ( maxcsn ) {
 		BER_BVZERO( maxcsn );
 	}
+	if ( foundit ) {
+		*foundit = 0;
+	}
 
-	ldap_pvt_thread_mutex_lock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_lock( &be->be_pcl_mutex );
 
-	LDAP_TAILQ_FOREACH( csne, op->o_bd->be_pending_csn_list, ce_csn_link ) {
+	LDAP_TAILQ_FOREACH( csne, be->be_pending_csn_list, ce_csn_link ) {
 		if ( csne->ce_opid == op->o_opid && csne->ce_connid == op->o_connid ) {
 			csne->ce_state = SLAP_CSN_COMMIT;
+			if ( foundit ) *foundit = 1;
 			break;
 		}
 	}
 
-	LDAP_TAILQ_FOREACH( csne, op->o_bd->be_pending_csn_list, ce_csn_link ) {
+	LDAP_TAILQ_FOREACH( csne, be->be_pending_csn_list, ce_csn_link ) {
 		if ( csne->ce_state == SLAP_CSN_COMMIT ) committed_csne = csne;
 		if ( csne->ce_state == SLAP_CSN_PENDING ) break;
 	}
 
 	if ( committed_csne && maxcsn ) *maxcsn = committed_csne->ce_csn;
-	ldap_pvt_thread_mutex_unlock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_unlock( &be->be_pcl_mutex );
 }
 
 void
 slap_rewind_commit_csn( Operation *op )
 {
 	struct slap_csn_entry *csne;
+	BackendDB *be = op->o_bd->bd_self;
 
-	ldap_pvt_thread_mutex_lock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_lock( &be->be_pcl_mutex );
 
-	LDAP_TAILQ_FOREACH( csne, op->o_bd->be_pending_csn_list, ce_csn_link ) {
+	LDAP_TAILQ_FOREACH( csne, be->be_pending_csn_list, ce_csn_link ) {
 		if ( csne->ce_opid == op->o_opid && csne->ce_connid == op->o_connid ) {
 			csne->ce_state = SLAP_CSN_PENDING;
 			break;
 		}
 	}
 
-	ldap_pvt_thread_mutex_unlock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_unlock( &be->be_pcl_mutex );
 }
 
 void
 slap_graduate_commit_csn( Operation *op )
 {
 	struct slap_csn_entry *csne;
+	BackendDB *be;
 
 	if ( op == NULL ) return;
 	if ( op->o_bd == NULL ) return;
+	be = op->o_bd->bd_self;
 
-#if 0
-	/* it is NULL when we get here from the frontendDB;
-	 * alternate fix: initialize frontendDB like all other backends */
-	assert( op->o_bd->be_pcl_mutexp != NULL );
-#endif
-	
-	if ( op->o_bd->be_pcl_mutexp == NULL ) return;
-
-	ldap_pvt_thread_mutex_lock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_lock( &be->be_pcl_mutex );
 
-	LDAP_TAILQ_FOREACH( csne, op->o_bd->be_pending_csn_list, ce_csn_link ) {
+	LDAP_TAILQ_FOREACH( csne, be->be_pending_csn_list, ce_csn_link ) {
 		if ( csne->ce_opid == op->o_opid && csne->ce_connid == op->o_connid ) {
-			LDAP_TAILQ_REMOVE( op->o_bd->be_pending_csn_list,
+			LDAP_TAILQ_REMOVE( be->be_pending_csn_list,
 				csne, ce_csn_link );
 			Debug( LDAP_DEBUG_SYNC, "slap_graduate_commit_csn: removing %p %s\n",
 				csne->ce_csn.bv_val, csne->ce_csn.bv_val, 0 );
@@ -110,7 +111,7 @@
 		}
 	}
 
-	ldap_pvt_thread_mutex_unlock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_unlock( &be->be_pcl_mutex );
 
 	return;
 }
@@ -161,22 +162,23 @@
 	struct berval *csn )
 {
 	struct slap_csn_entry *pending;
+	BackendDB *be = op->o_bd->bd_self;
 
 	pending = (struct slap_csn_entry *) ch_calloc( 1,
 			sizeof( struct slap_csn_entry ));
 
 	Debug( LDAP_DEBUG_SYNC, "slap_queue_csn: queing %p %s\n", csn->bv_val, csn->bv_val, 0 );
 
-	ldap_pvt_thread_mutex_lock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_lock( &be->be_pcl_mutex );
 
 	ber_dupbv( &pending->ce_csn, csn );
 	ber_bvreplace_x( &op->o_csn, &pending->ce_csn, op->o_tmpmemctx );
 	pending->ce_connid = op->o_connid;
 	pending->ce_opid = op->o_opid;
 	pending->ce_state = SLAP_CSN_PENDING;
-	LDAP_TAILQ_INSERT_TAIL( op->o_bd->be_pending_csn_list,
+	LDAP_TAILQ_INSERT_TAIL( be->be_pending_csn_list,
 		pending, ce_csn_link );
-	ldap_pvt_thread_mutex_unlock( op->o_bd->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_unlock( &be->be_pcl_mutex );
 }
 
 int
Index: servers/slapd/frontend.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/frontend.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- servers/slapd/frontend.c	19 Sep 2008 18:37:11 -0000	1.26
+++ servers/slapd/frontend.c	2 Nov 2008 06:58:50 -0000	1.27
@@ -108,11 +108,7 @@
 	frontendDB->be_def_limit.lms_s_pr_hide = 0;			/* don't hide number of entries left */
 	frontendDB->be_def_limit.lms_s_pr_total = 0;			/* number of total entries returned by pagedResults equal to hard limit */
 
-#if 0
-	/* FIXME: do we need this? */
-	frontendDB->be_pcl_mutexp = &frontendDB->be_pcl_mutex;
-	ldap_pvt_thread_mutex_init( frontendDB->be_pcl_mutexp );
-#endif
+	ldap_pvt_thread_mutex_init( &frontendDB->be_pcl_mutex );
 
 	/* suffix */
 	frontendDB->be_suffix = ch_calloc( 2, sizeof( struct berval ) );
Index: servers/slapd/slap.h
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slap.h,v
retrieving revision 1.860
retrieving revision 1.861
diff -u -r1.860 -r1.861
--- servers/slapd/slap.h	1 Nov 2008 14:16:49 -0000	1.860
+++ servers/slapd/slap.h	2 Nov 2008 06:58:50 -0000	1.861
@@ -1895,7 +1895,6 @@
 	BerVarray	be_update_refs;	/* where to refer modifying clients to */
 	struct		be_pcl	*be_pending_csn_list;
 	ldap_pvt_thread_mutex_t					be_pcl_mutex;
-	ldap_pvt_thread_mutex_t					*be_pcl_mutexp;
 	struct syncinfo_s						*be_syncinfo; /* For syncrepl */
 
 	void    *be_pb;         /* Netscape plugin */
Index: servers/slapd/overlays/pcache.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/overlays/pcache.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -r1.157 -r1.158
--- servers/slapd/overlays/pcache.c	24 Oct 2008 16:57:38 -0000	1.157
+++ servers/slapd/overlays/pcache.c	2 Nov 2008 06:58:50 -0000	1.158
@@ -3145,7 +3145,7 @@
 	cm->db = *be;
 	SLAP_DBFLAGS(&cm->db) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
 	cm->db.be_private = NULL;
-	cm->db.be_pcl_mutexp = &cm->db.be_pcl_mutex;
+	cm->db.bd_self = &cm->db;
 	cm->qm = qm;
 	cm->numattrsets = 0;
 	cm->num_entries_limit = 5;
Index: servers/slapd/overlays/translucent.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/overlays/translucent.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- servers/slapd/overlays/translucent.c	17 Oct 2008 15:40:49 -0000	1.56
+++ servers/slapd/overlays/translucent.c	2 Nov 2008 06:58:50 -0000	1.57
@@ -1268,7 +1268,6 @@
 	on->on_bi.bi_private = ov;
 	ov->db = *be;
 	ov->db.be_private = NULL;
-	ov->db.be_pcl_mutexp = &ov->db.be_pcl_mutex;
 	ov->defer_db_open = 1;
 
 	if ( !backend_db_init( "ldap", &ov->db, -1, NULL )) {
Index: servers/slapd/backend.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/backend.c,v
retrieving revision 1.402
retrieving revision 1.403
diff -u -r1.402 -r1.403
--- servers/slapd/backend.c	1 Nov 2008 14:16:49 -0000	1.402
+++ servers/slapd/backend.c	2 Nov 2008 06:58:50 -0000	1.403
@@ -594,8 +594,7 @@
 	be->be_requires = frontendDB->be_requires;
 	be->be_ssf_set = frontendDB->be_ssf_set;
 
-	be->be_pcl_mutexp = &be->be_pcl_mutex;
-	ldap_pvt_thread_mutex_init( be->be_pcl_mutexp );
+	ldap_pvt_thread_mutex_init( &be->be_pcl_mutex );
 
  	/* assign a default depth limit for alias deref */
 	be->be_max_deref_depth = SLAPD_DEFAULT_MAXDEREFDEPTH; 
openSUSE Build Service is sponsored by