]> git.sur5r.net Git - openldap/commitdiff
ITS#5973
authorQuanah Gibson-Mount <quanah@openldap.org>
Thu, 5 Mar 2009 21:23:14 +0000 (21:23 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 5 Mar 2009 21:23:14 +0000 (21:23 +0000)
CHANGES
servers/slapd/overlays/syncprov.c
servers/slapd/syncrepl.c

diff --git a/CHANGES b/CHANGES
index 61fe9c2c7046cca89a81129f4c55559df3e51cf6..9cc48bda9f2eef350cdbcae78f0c516b7ef9be9c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,11 +9,13 @@ OpenLDAP 2.4.16 Engineering
        Fixed libldap referral chasing (ITS#5980)
        Fixed slapd backglue with empty DBs (ITS#5986)
        Fixed slapd syncrepl newCookie sync messages (ITS#5972)
+       Fixed slapd syncrepl multiple CSN propagation (ITS#5973)
        Fixed slapd-bdb/hdb cachesize handling (ITS#5860)
        Fixed slapd-ldap/meta with broken AD results (ITS#5977)
        Fixed slapd-ldap/meta with invalid attrs again (ITS#5959)
        Fixed slapo-accesslog interaction with ppolicy (ITS#5979)
        Fixed slapo-syncprov newCookie sync messages (ITS#5972)
+       Fixed slapo-syncprov multiple CSN propagation (ITS#5973)
        Documentation
                admin24 clarified MMR URI requirements (ITS#5942,ITS#5987)
                slapd-ldap/meta(5) added missing TLS options (ITS#5989)
index 99055f58d7a62771b212bed0503a2dd2054e13f8..7520656cf7ddfac6416149b566d19261cc1f1437 100644 (file)
@@ -1658,6 +1658,57 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                maxcsn.bv_val = cbuf;
                maxcsn.bv_len = sizeof(cbuf);
                ldap_pvt_thread_rdwr_wlock( &si->si_csn_rwlock );
+
+               if ( op->o_dont_replicate &&
+                               op->orm_modlist->sml_op == LDAP_MOD_REPLACE &&
+                               op->orm_modlist->sml_desc == slap_schema.si_ad_contextCSN ) {
+                       /* Catch contextCSN updates from syncrepl. We have to look at
+                        * all the attribute values, as there may be more than one csn
+                        * that changed, and only one can be passed in the csn queue.
+                        */
+                       Modifications *mod = op->orm_modlist;
+                       int i, j, sid;
+
+                       for ( i=0; i<mod->sml_numvals; i++ ) {
+                               sid = slap_parse_csn_sid( &mod->sml_values[i] );
+
+                               for ( j=0; j<si->si_numcsns; j++ ) {
+                                       if ( sid == si->si_sids[j] ) {
+                                               if ( ber_bvcmp( &mod->sml_values[i], &si->si_ctxcsn[j] ) > 0 ) {
+                                                       ber_bvreplace( &si->si_ctxcsn[j], &mod->sml_values[i] );
+                                                       csn_changed = 1;
+                                               }
+                                               break;
+                                       }
+                               }
+
+                               if ( j == si->si_numcsns ) {
+                                       value_add_one( &si->si_ctxcsn, &mod->sml_values[i] );
+                                       si->si_numcsns++;
+                                       si->si_sids = ch_realloc( si->si_sids, si->si_numcsns *
+                                               sizeof(int));
+                                       si->si_sids[j] = sid;
+                                       csn_changed = 1;
+                               }
+                       }
+                       ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock );
+
+                       if ( csn_changed ) {
+                               ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
+                               have_psearches = ( si->si_ops != NULL );
+                               ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
+
+                               if ( have_psearches ) {
+                                       for ( sm = opc->smatches; sm; sm=sm->sm_next ) {
+                                               if ( sm->sm_op->s_op->o_abandon )
+                                                       continue;
+                                               syncprov_qresp( opc, sm->sm_op, LDAP_SYNC_NEW_COOKIE );
+                                       }
+                               }
+                       }
+                       return SLAP_CB_CONTINUE;
+               }
+
                slap_get_commit_csn( op, &maxcsn, &foundit );
                if ( BER_BVISEMPTY( &maxcsn ) && SLAP_GLUE_SUBORDINATE( op->o_bd )) {
                        /* syncrepl queues the CSN values in the db where
index 66223836559329513f8ad7927fe4133658e7831c..f10c36b600e72370bfcbf9ce80bfd6d659047fc3 100644 (file)
@@ -2887,12 +2887,11 @@ syncrepl_updateCookie(
 {
        Backend *be = op->o_bd;
        Modifications mod;
-       struct berval first = BER_BVNULL;
 #ifdef CHECK_CSN
        Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
 #endif
 
-       int rc, i, j;
+       int rc, i, j, csn_changed = 0;
        ber_len_t len;
 
        slap_callback cb = { NULL };
@@ -2934,13 +2933,7 @@ syncrepl_updateCookie(
                        if ( memcmp( syncCookie->ctxcsn[i].bv_val,
                                si->si_cookieState->cs_vals[j].bv_val, len ) > 0 ) {
                                mod.sml_values[j] = syncCookie->ctxcsn[i];
-                               if ( BER_BVISNULL( &first ) ) {
-                                       first = syncCookie->ctxcsn[i];
-
-                               } else if ( memcmp( syncCookie->ctxcsn[i].bv_val, first.bv_val, first.bv_len ) > 0 )
-                               {
-                                       first = syncCookie->ctxcsn[i];
-                               }
+                               csn_changed = 1;
                        }
                        break;
                }
@@ -2950,23 +2943,16 @@ syncrepl_updateCookie(
                                ( mod.sml_numvals+2 )*sizeof(struct berval), op->o_tmpmemctx );
                        mod.sml_values[mod.sml_numvals++] = syncCookie->ctxcsn[i];
                        BER_BVZERO( &mod.sml_values[mod.sml_numvals] );
-                       if ( BER_BVISNULL( &first ) ) {
-                               first = syncCookie->ctxcsn[i];
-                       } else if ( memcmp( syncCookie->ctxcsn[i].bv_val, first.bv_val, first.bv_len ) > 0 )
-                       {
-                               first = syncCookie->ctxcsn[i];
-                       }
+                       csn_changed = 1;
                }
        }
        /* Should never happen, ITS#5065 */
-       if ( BER_BVISNULL( &first )) {
+       if ( !csn_changed ) {
                ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
                op->o_tmpfree( mod.sml_values, op->o_tmpmemctx );
                return 0;
        }
        op->o_bd = si->si_wbe;
-       slap_queue_csn( op, &first );
-
        op->o_tag = LDAP_REQ_MODIFY;
 
        cb.sc_response = null_callback;