]> git.sur5r.net Git - openldap/commitdiff
Always log outgoing cookie, just use op->o_csn instead of commit_csn since
authorHoward Chu <hyc@openldap.org>
Sat, 21 Nov 2009 02:37:53 +0000 (02:37 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 21 Nov 2009 02:37:53 +0000 (02:37 +0000)
all responses are now serialized.

servers/slapd/overlays/syncprov.c

index dcaf6887de5a05c993286a4d46cd6bf2d5e5766b..6942d2055d9ae5b76b0faaf0028a4a8481fe541d 100644 (file)
@@ -792,15 +792,13 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so,
        }
 
 #ifdef LDAP_DEBUG
-       if ( !BER_BVISNULL( &cookie )) {
-               if ( so->s_sid > 0 ) {
-                       Debug( LDAP_DEBUG_SYNC, "syncprov_sendresp: to=%03x, cookie=%s\n",
-                               so->s_sid, cookie.bv_val , 0 );
-               } else {
-                       Debug( LDAP_DEBUG_SYNC, "syncprov_sendresp: cookie=%s\n",
-                               cookie.bv_val, 0, 0 );
-               }
-       }               
+       if ( so->s_sid > 0 ) {
+               Debug( LDAP_DEBUG_SYNC, "syncprov_sendresp: to=%03x, cookie=%s\n",
+                       so->s_sid, cookie.bv_val ? cookie.bv_val : "", 0 );
+       } else {
+               Debug( LDAP_DEBUG_SYNC, "syncprov_sendresp: cookie=%s\n",
+                       cookie.bv_val ? cookie.bv_val : "", 0, 0 );
+       }
 #endif
 
        e_uuid.e_attrs = &a_uuid;
@@ -1663,7 +1661,7 @@ syncprov_op_response( Operation *op, SlapReply *rs )
        {
                struct berval maxcsn;
                char cbuf[LDAP_PVT_CSNSTR_BUFSIZE];
-               int do_check = 0, have_psearches, foundit, csn_changed = 0;
+               int do_check = 0, have_psearches;
 
                ldap_pvt_thread_mutex_lock( &si->si_resp_mutex );
 
@@ -1681,7 +1679,7 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                         * that changed, and only one can be passed in the csn queue.
                         */
                        Modifications *mod = op->orm_modlist;
-                       int i, j, sid;
+                       int i, j, sid, csn_changed = 0;
 
                        for ( i=0; i<mod->sml_numvals; i++ ) {
                                sid = slap_parse_csn_sid( &mod->sml_values[i] );
@@ -1723,20 +1721,7 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                        goto leave;
                }
 
-               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
-                        * it is configured , not where the changes are made.
-                        * So look for a value in the glue db if we didn't
-                        * find any in this db.
-                        */
-                       BackendDB *be = op->o_bd;
-                       op->o_bd = select_backend( &be->be_nsuffix[0], 1);
-                       maxcsn.bv_val = cbuf;
-                       maxcsn.bv_len = sizeof(cbuf);
-                       slap_get_commit_csn( op, &maxcsn, &foundit );
-                       op->o_bd = be;
-               }
+               maxcsn = op->o_csn;
                if ( !BER_BVISEMPTY( &maxcsn ) ) {
                        int i, sid;
 #ifdef CHECK_CSN
@@ -1748,7 +1733,6 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                                if ( sid == si->si_sids[i] ) {
                                        if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn[i] ) > 0 ) {
                                                ber_bvreplace( &si->si_ctxcsn[i], &maxcsn );
-                                               csn_changed = 1;
                                        }
                                        break;
                                }
@@ -1756,18 +1740,11 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                        /* It's a new SID for us */
                        if ( i == si->si_numcsns ) {
                                value_add_one( &si->si_ctxcsn, &maxcsn );
-                               csn_changed = 1;
                                si->si_numcsns++;
                                si->si_sids = ch_realloc( si->si_sids, si->si_numcsns *
                                        sizeof(int));
                                si->si_sids[i] = sid;
                        }
-#if 0
-               } 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;
-#endif
                }
 
                /* Don't do any processing for consumer contextCSN updates */
@@ -1806,10 +1783,8 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                        ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock );
                }
 
-               /* only update consumer ctx if this is a newer csn */
-               if ( csn_changed ) {
-                       opc->sctxcsn = maxcsn;
-               }
+               /* always update consumer ctx even if this is an old csn */
+               opc->sctxcsn = maxcsn;
 
                /* Handle any persistent searches */
                ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );