1
--- openldap.orig/servers/slapd/ctxcsn.c 2009/01/22 00:01:01 1.40.2.11
2
+++ openldap/servers/slapd/ctxcsn.c 2009/02/17 00:06:01 1.40.2.12
4
/* ctxcsn.c -- Context CSN Management Routines */
5
-/* $OpenLDAP: pkg/ldap/servers/slapd/ctxcsn.c,v 1.40.2.11 2009/01/22 00:01:01 kurt Exp $ */
6
+/* $OpenLDAP: pkg/ldap/servers/slapd/ctxcsn.c,v 1.40.2.12 2009/02/17 00:06:01 quanah Exp $ */
7
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
9
* Copyright 2003-2009 The OpenLDAP Foundation.
11
const struct berval slap_ldapsync_cn_bv = BER_BVC("cn=ldapsync");
14
+/* maxcsn->bv_val must point to a char buf[LDAP_LUTIL_CSNSTR_BUFSIZE] */
19
BackendDB *be = op->o_bd->bd_self;
22
- BER_BVZERO( maxcsn );
23
+ assert( maxcsn->bv_val != NULL );
24
+ assert( maxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE );
29
if ( csne->ce_state == SLAP_CSN_PENDING ) break;
32
- if ( committed_csne && maxcsn ) *maxcsn = committed_csne->ce_csn;
34
+ if ( committed_csne ) {
35
+ if ( committed_csne->ce_csn.bv_len < maxcsn->bv_len )
36
+ maxcsn->bv_len = committed_csne->ce_csn.bv_len;
37
+ AC_MEMCPY( maxcsn->bv_val, committed_csne->ce_csn.bv_val,
41
+ maxcsn->bv_val[0] = 0;
44
ldap_pvt_thread_mutex_unlock( &be->be_pcl_mutex );
47
--- openldap.orig/servers/slapd/syncrepl.c 2009/02/10 16:43:11 1.254.2.61
48
+++ openldap/servers/slapd/syncrepl.c 2009/02/17 00:06:01 1.254.2.62
50
/* syncrepl.c -- Replication Engine which uses the LDAP Sync protocol */
51
-/* $OpenLDAP: pkg/ldap/servers/slapd/syncrepl.c,v 1.254.2.61 2009/02/10 16:43:11 quanah Exp $ */
52
+/* $OpenLDAP: pkg/ldap/servers/slapd/syncrepl.c,v 1.254.2.62 2009/02/17 00:06:01 quanah Exp $ */
53
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
55
* Copyright 2003-2009 The OpenLDAP Foundation.
57
Backend *be = op->o_bd;
59
struct berval first = BER_BVNULL;
61
+ Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
66
@@ -2892,6 +2895,15 @@
68
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
71
+ for ( i=0; i<syncCookie->numcsns; i++ ) {
72
+ assert( !syn->ssyn_validate( syn, syncCookie->ctxcsn+i ));
74
+ for ( i=0; i<si->si_cookieState->cs_num; i++ ) {
75
+ assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i ));
79
/* clone the cookieState CSNs so we can Replace the whole thing */
80
mod.sml_numvals = si->si_cookieState->cs_num;
81
mod.sml_values = op->o_tmpalloc(( mod.sml_numvals+1 )*sizeof(struct berval), op->o_tmpmemctx );
82
@@ -2993,6 +3005,12 @@
83
BER_BVZERO( &op->o_csn );
84
if ( mod.sml_next ) slap_mods_free( mod.sml_next, 1 );
85
op->o_tmpfree( mod.sml_values, op->o_tmpmemctx );
88
+ for ( i=0; i<si->si_cookieState->cs_num; i++ ) {
89
+ assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i ));
95
--- openldap.orig/servers/slapd/overlays/syncprov.c 2009/01/30 18:49:57 1.147.2.44
96
+++ openldap/servers/slapd/overlays/syncprov.c 2009/02/17 00:06:01 1.147.2.45
98
-/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.44 2009/01/30 18:49:57 quanah Exp $ */
99
+/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.45 2009/02/17 00:06:01 quanah Exp $ */
100
/* syncprov.c - syncrepl provider */
101
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
111
/* A modify request on a particular entry */
112
typedef struct modinst {
113
struct modinst *mi_next;
117
if ( ber_bvcmp( &si->si_ctxcsn[maxid], &maxcsn )) {
119
+ Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
120
+ assert( !syn->ssyn_validate( syn, &maxcsn ));
122
ber_bvreplace( &si->si_ctxcsn[maxid], &maxcsn );
123
si->si_numops++; /* ensure a checkpoint */
125
@@ -1339,7 +1347,14 @@
126
SlapReply rsm = { 0 };
127
slap_callback cb = {0};
130
+ Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
133
+ for ( i=0; i<si->si_numcsns; i++ ) {
134
+ assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i ));
137
mod.sml_numvals = si->si_numcsns;
138
mod.sml_values = si->si_ctxcsn;
139
mod.sml_nvalues = NULL;
140
@@ -1367,6 +1382,11 @@
141
if ( mod.sml_next != NULL ) {
142
slap_mods_free( mod.sml_next, 1 );
145
+ for ( i=0; i<si->si_numcsns; i++ ) {
146
+ assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i ));
152
@@ -1608,15 +1628,17 @@
154
if ( rs->sr_err == LDAP_SUCCESS )
156
- struct berval maxcsn = BER_BVNULL;
157
+ struct berval maxcsn;
158
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
159
int do_check = 0, have_psearches, foundit;
161
/* Update our context CSN */
163
+ maxcsn.bv_val = cbuf;
164
+ maxcsn.bv_len = sizeof(cbuf);
165
ldap_pvt_thread_rdwr_wlock( &si->si_csn_rwlock );
166
slap_get_commit_csn( op, &maxcsn, &foundit );
167
- if ( BER_BVISNULL( &maxcsn ) && SLAP_GLUE_SUBORDINATE( op->o_bd )) {
168
+ if ( BER_BVISEMPTY( &maxcsn ) && SLAP_GLUE_SUBORDINATE( op->o_bd )) {
169
/* syncrepl queues the CSN values in the db where
170
* it is configured , not where the changes are made.
171
* So look for a value in the glue db if we didn't
172
@@ -1624,12 +1646,17 @@
174
BackendDB *be = op->o_bd;
175
op->o_bd = select_backend( &be->be_nsuffix[0], 1);
176
+ maxcsn.bv_val = cbuf;
177
+ maxcsn.bv_len = sizeof(cbuf);
178
slap_get_commit_csn( op, &maxcsn, &foundit );
181
- if ( !BER_BVISNULL( &maxcsn ) ) {
182
+ if ( !BER_BVISEMPTY( &maxcsn ) ) {
184
- strcpy( cbuf, maxcsn.bv_val );
186
+ Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
187
+ assert( !syn->ssyn_validate( syn, &maxcsn ));
189
sid = slap_parse_csn_sid( &maxcsn );
190
for ( i=0; i<si->si_numcsns; i++ ) {
191
if ( sid == si->si_sids[i] ) {
192
@@ -1685,8 +1712,7 @@
194
/* only update consumer ctx if this is the greatest csn */
195
if ( bvmatch( &maxcsn, &op->o_csn )) {
196
- opc->sctxcsn.bv_len = maxcsn.bv_len;
197
- opc->sctxcsn.bv_val = cbuf;
198
+ opc->sctxcsn = maxcsn;
201
/* Handle any persistent searches */
202
@@ -1750,6 +1776,7 @@
204
a.a_vals = si->si_ctxcsn;
205
a.a_nvals = a.a_vals;
206
+ a.a_numvals = si->si_numcsns;
208
rs->sr_err = access_allowed( op, &e, op->oq_compare.rs_ava->aa_desc,
209
&op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL );