Commit 6659cf3e authored by Jong Hyuk Choi's avatar Jong Hyuk Choi
Browse files

LDAP Sync protocol change : state mode (add+present) and log mode (add+delete)

parent fcc59c64
......@@ -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
......
......@@ -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,
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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 :
......
......@@ -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 \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment