]> git.sur5r.net Git - openldap/commitdiff
LDAP Sync protocol change : state mode (add+present) and log mode (add+delete)
authorJong Hyuk Choi <jongchoi@openldap.org>
Thu, 14 Aug 2003 16:27:36 +0000 (16:27 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Thu, 14 Aug 2003 16:27:36 +0000 (16:27 +0000)
include/ldap.h
servers/slapd/back-bdb/search.c
servers/slapd/config.c
servers/slapd/slap.h
servers/slapd/syncrepl.c
tests/scripts/test020-syncreplication-cascading

index da0459ca666820d0481c2844736ccf7cde73822f..2fa360a33c32095b378ed49d6704e80cd06bd3b1 100644 (file)
@@ -209,8 +209,14 @@ typedef struct ldapcontrol {
 #define LDAP_CONTROL_SYNC_DONE "1.3.6.1.4.1.4203.666.5.8"
 #define LDAP_SYNC_INFO                 "1.3.6.1.4.1.4203.666.10.2"
 
-#define LDAP_SYNC_REFRESH_DONE 0
-#define LDAP_SYNC_NEW_COOKIE   1
+#define LDAP_SYNC_NEW_COOKIE           0
+#define LDAP_SYNC_STATE_MODE_DONE      1
+#define        LDAP_SYNC_LOG_MODE_DONE         2
+#define LDAP_SYNC_REFRESH_DONE         3
+
+#define LDAP_SYNC_STATE_MODE           0
+#define LDAP_SYNC_LOG_MODE                     1
+#define LDAP_SYNC_PERSIST_MODE         2
 
 #define LDAP_SYNC_PRESENT              0
 #define LDAP_SYNC_ADD                  1
index 3772dfe4ba730ec6eaff0970a3f530b8dc892d52..76ef07c4e094dfd8f321bc864654c40946411bd5 100644 (file)
@@ -380,8 +380,8 @@ int bdb_search( Operation *op, SlapReply *rs )
        AttributeName   *attrs;
 
 #ifdef LDAP_SYNC
-       Filter          cookief, csnfnot, csnfeq, csnfand, csnfge;
-       AttributeAssertion aa_ge, aa_eq;
+       Filter          cookief, csnfnot, csnfeq, csnfand, csnfge, omitcsnf, omitcsnfle;
+       AttributeAssertion aa_ge, aa_eq, aa_le;
        int             entry_count = 0;
 #if 0
        struct berval   entrycsn_bv = { 0, NULL };
@@ -1230,13 +1230,18 @@ loop_continue:
        if (!IS_PSEARCH) {
 #ifdef LDAP_SYNC
        if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
+               rs->sr_err = LDAP_SUCCESS;
+               rs->sr_rspoid = LDAP_SYNC_INFO;
+               rs->sr_ctrls = NULL;
+               bdb_send_ldap_intermediate( sop, rs,
+                       LDAP_SYNC_STATE_MODE_DONE, &latest_entrycsn_bv );
+
+               /* If changelog is supported, this is where to process it */
+
                if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
                        /* refreshAndPersist mode */
-                       rs->sr_err = LDAP_SUCCESS;
-                       rs->sr_rspoid = LDAP_SYNC_INFO;
-                       rs->sr_ctrls = NULL;
                        bdb_send_ldap_intermediate( sop, rs,
-                               LDAP_SYNC_REFRESH_DONE, &latest_entrycsn_bv );
+                               LDAP_SYNC_LOG_MODE_DONE, &latest_entrycsn_bv );
                } else {
                        /* refreshOnly mode */
                        bdb_build_sync_done_ctrl( sop, rs, ctrls,
index 02236eb0c0fcdbe219e5a2797ee49a9c220eba99..c71b9aca2c4a89487f85ab2a896b0a4e885420cd 100644 (file)
@@ -2767,6 +2767,7 @@ add_syncrepl(
        si->slimit = -1;
        si->syncUUID = NULL;
        si->syncUUID_ndn = NULL;
+       si->sync_mode = LDAP_SYNC_STATE_MODE;
 
        si->presentlist = NULL;
        LDAP_LIST_INIT( &si->nonpresentlist );
index ca56418b9557ee32f373e5d63e12f5803d6ea93b..01a41173b2f377ad90f92818aca315dbf352c081 100644 (file)
@@ -1337,6 +1337,7 @@ typedef struct syncinfo_s {
         struct berval  *syncUUID;
                struct berval   *syncUUID_ndn;
         Avlnode                        *presentlist;
+               int                             sync_mode;
                LDAP_LIST_HEAD(np, nonpresent_entry) nonpresentlist;
 } syncinfo_t;
 
index 81f726ac350324c61b1851f098caaffa45c9639a..765e3f6a66376a4263986f4c63b50c9962d71711 100644 (file)
@@ -247,6 +247,8 @@ do_syncrepl(
                return NULL;
        }
 
+       si->sync_mode = LDAP_SYNC_STATE_MODE;
+
        /* Init connection to master */
 
        rc = ldap_initialize( &ld, si->provideruri );
@@ -538,7 +540,8 @@ do_syncrepl(
                                        if ( syncCookie.bv_len ) {
                                                syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
                                        }
-                                       syncrepl_del_nonpresent( ld, &op );
+                                       if ( si->sync_mode == LDAP_SYNC_STATE_MODE )
+                                               syncrepl_del_nonpresent( ld, &op );
                                        if ( ctrl_ber )
                                                ber_free( ctrl_ber, 1 );
                                        goto done;
@@ -553,9 +556,15 @@ do_syncrepl(
                                        res_ber = ber_init( retdata );
                                        ber_scanf( res_ber, "{e" /*"}"*/, &syncstate );
 
-                                       if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
+                                       if ( syncstate == LDAP_SYNC_STATE_MODE_DONE ) {
                                                syncrepl_del_nonpresent( ld, &op );
-                                       } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ) {
+                                               si->sync_mode = LDAP_SYNC_LOG_MODE;
+                                       } else if ( syncstate == LDAP_SYNC_LOG_MODE_DONE ) {
+                                               si->sync_mode = LDAP_SYNC_PERSIST_MODE;
+                                       } else if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
+                                               si->sync_mode = LDAP_SYNC_PERSIST_MODE;
+                                       } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ||
+                                                               syncstate != LDAP_SYNC_LOG_MODE_DONE ) {
 #ifdef NEW_LOGGING
                                                LDAP_LOG( OPERATION, ERR,
                                                        "do_syncrepl : unknown sync info\n", 0, 0, 0 );
@@ -986,7 +995,7 @@ syncrepl_entry(
        cb.sc_response = null_callback;
        cb.sc_private = si;
 
-       if ( rc == LDAP_SUCCESS && si->syncUUID_ndn ) {
+       if ( rc == LDAP_SUCCESS && si->syncUUID_ndn && si->sync_mode != LDAP_SYNC_LOG_MODE ) {
                op->o_req_dn = *si->syncUUID_ndn;
                op->o_req_ndn = *si->syncUUID_ndn;
                op->o_tag = LDAP_REQ_DELETE;
@@ -1062,7 +1071,13 @@ syncrepl_entry(
                }
 
        case LDAP_SYNC_DELETE :
-               /* Already deleted */
+               if ( si->sync_mode == LDAP_SYNC_LOG_MODE ) {
+                       op->o_req_dn = *si->syncUUID_ndn;
+                       op->o_req_ndn = *si->syncUUID_ndn;
+                       op->o_tag = LDAP_REQ_DELETE;
+                       rc = be->be_delete( op, &rs );
+               }
+               /* Already deleted otherwise */
                return 1;
 
        default :
index dc332ff97235fa106516281529715d109ee7226e..e84d59528146f800b8cf4e9beb06abd48720a51e 100755 (executable)
@@ -205,8 +205,8 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "Waiting 30 seconds for syncrepl to receive changes..."
-sleep 30
+echo "Waiting 60 seconds for syncrepl to receive changes..."
+sleep 60
 
 echo "Using ldapmodify to modify master directory..."
 
@@ -287,8 +287,8 @@ changetype: delete
 
 EOMODS
 
-echo "Waiting 30 seconds for syncrepl to receive changes..."
-sleep 30
+echo "Waiting 60 seconds for syncrepl to receive changes..."
+sleep 60
 
 echo "Using ldapsearch to read all the entries from the master..."
 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \