]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
More syncprov fixes. test019 now passes.
[openldap] / servers / slapd / syncrepl.c
index a043f13f8f5ed52d269b3f0c0ee799bcfab663e7..25a09460621b939b6e7909a3a123a3dae2866610 100644 (file)
@@ -48,9 +48,6 @@ static int dn_callback( struct slap_op *, struct slap_rep * );
 static int nonpresent_callback( struct slap_op *, struct slap_rep * );
 static int null_callback( struct slap_op *, struct slap_rep * );
 
-static int si_refreshDelete = 0;
-static int si_refreshPresent = 0;
-
 static AttributeDescription *sync_descs[4];
 
 struct runqueue_s syncrepl_rq;
@@ -616,7 +613,7 @@ do_syncrep2(
                                if ( syncrepl_message_to_entry( si, op, msg,
                                        &modlist, &entry, syncstate ) == LDAP_SUCCESS ) {
                                        rc_efree = syncrepl_entry( si, op, entry, modlist,
-                                               syncstate, &syncUUID, &syncCookie_req );
+                                               syncstate, &syncUUID, &syncCookie_req, syncCookie.ctxcsn );
                                        if ( syncCookie.octet_str &&
                                                !BER_BVISNULL( &syncCookie.octet_str[0] ) )
                                        {
@@ -724,7 +721,7 @@ do_syncrep2(
                                                        "do_syncrep2: %s - %s%s\n", 
                                                        "LDAP_RES_INTERMEDIATE", 
                                                        "REFRESH_DELETE\n", "\n" );
-                                               si_refreshDelete = 1;
+                                               si->si_refreshDelete = 1;
                                        case LDAP_TAG_SYNC_REFRESH_PRESENT:
                                                Debug( LDAP_DEBUG_SYNC,
                                                        "do_syncrep2: %s - %s%s\n", 
@@ -732,8 +729,8 @@ do_syncrep2(
                                                        si_tag == LDAP_TAG_SYNC_REFRESH_PRESENT ?
                                                        "REFRESH_PRESENT" : "REFRESH_DELETE",
                                                        "\n" );
-                                               si_refreshDelete = 1;
-                                               si_refreshPresent = 1;
+                                               si->si_refreshDelete = 1;
+                                               si->si_refreshPresent = 1;
                                                ber_scanf( ber, "t{" /*"}"*/, &tag );
                                                if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
                                                {
@@ -824,7 +821,7 @@ do_syncrep2(
                                                syncrepl_updateCookie( si, op, psub, &syncCookie);
                                        }
 
-                                       if ( si_refreshPresent == 1 ) {
+                                       if ( si->si_refreshPresent == 1 ) {
                                                if ( match < 0 ) {
                                                        syncrepl_del_nonpresent( op, si );
                                                }
@@ -893,6 +890,7 @@ do_syncrepl(
        syncinfo_t *si = ( syncinfo_t * ) rtask->arg;
        Connection conn = {0};
        Operation op = {0};
+       Opheader ohdr = {0};
        int rc = LDAP_SUCCESS;
        int first = 0;
        int dostop = 0;
@@ -921,7 +919,7 @@ do_syncrepl(
                return NULL;
        }
 
-       connection_fake_init( &conn, &op, ctx );
+       connection_fake_init( &conn, &op, &ohdr, ctx );
 
        /* use global malloc for now */
        op.o_tmpmemctx = NULL;
@@ -929,21 +927,14 @@ do_syncrepl(
 
        op.o_dn = si->si_updatedn;
        op.o_ndn = si->si_updatedn;
-       op.o_managedsait = 1;
+       op.o_managedsait = SLAP_CONTROL_NONCRITICAL;
        op.o_bd = be = si->si_be;
 
-       op.o_sync_state.ctxcsn = NULL;
-       op.o_sync_state.sid = -1;
-       op.o_sync_state.octet_str = NULL;
-       op.o_sync_slog_size = -1;
-       LDAP_STAILQ_FIRST( &op.o_sync_slog_list ) = NULL;
-       op.o_sync_slog_list.stqh_last = &LDAP_STAILQ_FIRST(&op.o_sync_slog_list);
-
        /* Establish session, do search */
        if ( !si->si_ld ) {
                first = 1;
-               si_refreshDelete = 0;
-               si_refreshPresent = 0;
+               si->si_refreshDelete = 0;
+               si->si_refreshPresent = 0;
                rc = do_syncrep1( &op, si );
        }
 
@@ -1171,7 +1162,8 @@ syncrepl_entry(
        Modifications* modlist,
        int syncstate,
        struct berval* syncUUID,
-       struct sync_cookie* syncCookie_req )
+       struct sync_cookie* syncCookie_req,
+       struct berval* syncCSN )
 {
        Backend *be = op->o_bd;
        slap_callback   cb = { NULL };
@@ -1195,38 +1187,35 @@ syncrepl_entry(
        struct berval org_ndn = BER_BVNULL;
        int     org_managedsait;
 
-       Debug( LDAP_DEBUG_SYNC, "%s: %s",
-                               "syncrepl_entry",
-                               "LDAP_RES_SEARCH_ENTRY", 0 );
        switch( syncstate ) {
        case LDAP_SYNC_PRESENT:
-               Debug( LDAP_DEBUG_SYNC, "%s: %s",
+               Debug( LDAP_DEBUG_SYNC, "%s: %s\n",
                                        "syncrepl_entry",
-                                       "LDAP_SYNC_PRESENT", "\n" );
+                                       "LDAP_RES_SEARCH_ENTRY(LDAP_SYNC_PRESENT)", 0 );
                break;
        case LDAP_SYNC_ADD:
-               Debug( LDAP_DEBUG_SYNC, "%s: %s",
+               Debug( LDAP_DEBUG_SYNC, "%s: %s\n",
                                        "syncrepl_entry",
-                                       "LDAP_SYNC_ADD", "\n" );
+                                       "LDAP_RES_SEARCH_ENTRY(LDAP_SYNC_ADD)", 0 );
                break;
        case LDAP_SYNC_DELETE:
-               Debug( LDAP_DEBUG_SYNC, "%s: %s",
+               Debug( LDAP_DEBUG_SYNC, "%s: %s\n",
                                        "syncrepl_entry",
-                                       "LDAP_SYNC_DELETE", "\n" );
+                                       "LDAP_RES_SEARCH_ENTRY(LDAP_SYNC_DELETE)", 0 );
                break;
        case LDAP_SYNC_MODIFY:
-               Debug( LDAP_DEBUG_SYNC, "%s: %s",
+               Debug( LDAP_DEBUG_SYNC, "%s: %s\n",
                                        "syncrepl_entry",
-                                       "LDAP_SYNC_MODIFY", "\n" );
+                                       "LDAP_RES_SEARCH_ENTRY(LDAP_SYNC_MODIFY)", 0 );
                break;
        default:
-               Debug( LDAP_DEBUG_ANY, "%s: %s",
+               Debug( LDAP_DEBUG_ANY, "%s: %s\n",
                                        "syncrepl_entry",
-                                       "UNKNONW syncstate", "\n" );
+                                       "LDAP_RES_SEARCH_ENTRY(UNKNOWN syncstate)", 0 );
        }
 
        if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) {
-               if ( !si_refreshPresent ) {
+               if ( !si->si_refreshPresent ) {
                        syncuuid_bv = ber_dupbv( NULL, syncUUID );
                        avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
                                syncuuid_cmp, avl_dup_error );
@@ -1304,6 +1293,7 @@ syncrepl_entry(
        if ( rs_search.sr_err == LDAP_SUCCESS &&
                 !BER_BVISNULL( &si->si_syncUUID_ndn ))
        {
+#if 0
                char *subseq_ptr;
 
                if ( syncstate != LDAP_SYNC_DELETE ) {
@@ -1316,6 +1306,7 @@ syncrepl_entry(
                        subseq_ptr += 4;
                        *subseq_ptr = '1';
                }
+#endif
                
                op->o_req_dn = si->si_syncUUID_ndn;
                op->o_req_ndn = si->si_syncUUID_ndn;
@@ -1332,7 +1323,7 @@ syncrepl_entry(
                org_managedsait = get_manageDSAit( op );
                op->o_dn = op->o_bd->be_rootdn;
                op->o_ndn = op->o_bd->be_rootndn;
-               op->o_managedsait = 1;
+               op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 
                while ( rs_delete.sr_err == LDAP_SUCCESS && op->o_delete_glue_parent ) {
                        op->o_delete_glue_parent = 0;
@@ -1356,7 +1347,9 @@ syncrepl_entry(
                op->o_req_ndn = org_req_ndn;
                op->o_delete_glue_parent = 0;
 
+#if 0
                op->o_no_psearch = 0;
+#endif
        }
 
        switch ( syncstate ) {
@@ -1455,7 +1448,6 @@ syncrepl_entry(
        }
 
 done :
-
        if ( !BER_BVISNULL( &syncUUID_strrep ) ) {
                slap_sl_free( syncUUID_strrep.bv_val, op->o_tmpmemctx );
                BER_BVZERO( &syncUUID_strrep );
@@ -1489,7 +1481,7 @@ syncrepl_del_nonpresent(
        Modifications *mlnext;
        Modifications *mod;
        Modifications *modlist = NULL;
-       Modifications **modtail = &modlist;
+       Modifications **modtail;
        AttributeName   an[2];
 
        struct berval pdn = BER_BVNULL;
@@ -1523,13 +1515,13 @@ syncrepl_del_nonpresent(
        op->ors_filterstr = si->si_filterstr;
 
        op->o_nocaching = 1;
-       op->o_managedsait = 0;
+       op->o_managedsait = SLAP_CONTROL_NONE;
 
        if ( limits_check( op, &rs_search ) == 0 ) {
                rc = be->be_search( op, &rs_search );
        }
 
-       op->o_managedsait = 1;
+       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
        op->o_nocaching = 0;
 
        if ( op->ors_filter ) filter_free_x( op, op->ors_filter );
@@ -1549,6 +1541,7 @@ syncrepl_del_nonpresent(
                        rc = op->o_bd->be_delete( op, &rs_delete );
 
                        if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
+                               modtail = &modlist;
                                mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
                                mod->sml_op = LDAP_MOD_REPLACE;
                                mod->sml_desc = slap_schema.si_ad_objectClass;
@@ -1583,7 +1576,7 @@ syncrepl_del_nonpresent(
                        org_managedsait = get_manageDSAit( op );
                        op->o_dn = op->o_bd->be_rootdn;
                        op->o_ndn = op->o_bd->be_rootndn;
-                       op->o_managedsait = 1;
+                       op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
 
                        while ( rs_delete.sr_err == LDAP_SUCCESS &&
                                        op->o_delete_glue_parent ) {
@@ -1892,6 +1885,8 @@ syncrepl_updateCookie(
        op->o_req_dn = e->e_name;
        op->o_req_ndn = e->e_nname;
 
+       slap_queue_csn( op, syncCookie->ctxcsn );
+
        /* update persistent cookie */
 update_cookie_retry:
        op->o_tag = LDAP_REQ_MODIFY;
@@ -1926,6 +1921,7 @@ update_cookie_retry:
                                "be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
                }
        }
+       slap_graduate_commit_csn( op );
 
        if ( e != NULL ) {
                entry_free( e );