const char *text;
int slog_found = 0;
+ BerVarray syncUUID_set = NULL;
+ int syncUUID_set_cnt = 0;
+
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY, "bdb_search\n", 0, 0, 0 );
#else
result = send_search_entry( sop, rs );
if ( cookie.bv_val )
ch_free( cookie.bv_val );
- ch_free( ctrls[num_ctrls-1]->ldctl_value.bv_val );
- ch_free( ctrls[--num_ctrls] );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
+ sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
}
}
} else {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
- rs->sr_err = slap_build_sync_state_ctrl( sop,
- rs, e, entry_sync_state, ctrls,
- num_ctrls++, 0, NULL );
-
- if ( rs->sr_err != LDAP_SUCCESS ) goto done;
- rs->sr_ctrls = ctrls;
if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */
+ rs->sr_err = slap_build_sync_state_ctrl( sop,
+ rs, e, entry_sync_state, ctrls,
+ num_ctrls++, 0, NULL );
+ if ( rs->sr_err != LDAP_SUCCESS ) goto done;
+ rs->sr_ctrls = ctrls;
rs->sr_attrs = sop->oq_search.rs_attrs;
result = send_search_entry( sop, rs );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
+ sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
+ ctrls[num_ctrls] = NULL;
+ rs->sr_ctrls = NULL;
} else { /* PRESENT */
if ( sync_send_present_mode ) {
- rs->sr_attrs = &null_attr;
- result = send_search_entry( sop, rs );
+ result = slap_build_syncUUID_set( sop,
+ &syncUUID_set, e );
+ if ( result <= 0 ) {
+ result = -1;
+ } else {
+ syncUUID_set_cnt++;
+ if ( syncUUID_set_cnt == SLAP_SYNCUUID_SET_SIZE ) {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = LDAP_SYNC_INFO;
+ rs->sr_ctrls = NULL;
+ result = slap_send_syncinfo( sop, rs,
+ LDAP_TAG_SYNC_ID_SET,
+ NULL, 0, syncUUID_set, 0 );
+ if ( result != LDAP_SUCCESS )
+ result = -1;
+ ber_bvarray_free_x( syncUUID_set,
+ sop->o_tmpmemctx );
+ syncUUID_set = NULL;
+ syncUUID_set_cnt = 0;
+ }
+ }
} else {
result = 1;
}
}
-
- ch_free( ctrls[num_ctrls-1]->ldctl_value.bv_val );
- ch_free( ctrls[--num_ctrls] );
- ctrls[num_ctrls] = NULL;
- rs->sr_ctrls = NULL;
} else {
rs->sr_attrs = sop->oq_search.rs_attrs;
rs->sr_ctrls = NULL;
ldap_pvt_thread_yield();
}
+ if ( syncUUID_set_cnt > 0 ) {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = LDAP_SYNC_INFO;
+ rs->sr_ctrls = NULL;
+ slap_send_syncinfo( sop, rs, LDAP_TAG_SYNC_ID_SET,
+ NULL, 0, syncUUID_set, 0 );
+ ber_bvarray_free_x( syncUUID_set, sop->o_tmpmemctx );
+ syncUUID_set_cnt = 0;
+ }
+
nochange:
if (!IS_PSEARCH) {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
- rs->sr_err = LDAP_SUCCESS;
- rs->sr_rspoid = LDAP_SYNC_INFO;
- rs->sr_ctrls = NULL;
-
if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
struct berval cookie;
slap_compose_sync_cookie( sop, &cookie,
sop->o_sync_state.sid );
if ( sync_send_present_mode ) {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = LDAP_SYNC_INFO;
+ rs->sr_ctrls = NULL;
slap_send_syncinfo( sop, rs,
LDAP_TAG_SYNC_REFRESH_PRESENT, &cookie, 1, NULL, 0 );
} else {
}
if ( slog_found ) {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = NULL;
+ rs->sr_ctrls = NULL;
slap_send_session_log( op, ps_list, rs );
}
ldap_pvt_thread_mutex_unlock( &bdb->bi_pslist_mutex );
}
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_rspoid = LDAP_SYNC_INFO;
+ rs->sr_ctrls = NULL;
slap_send_syncinfo( sop, rs,
LDAP_TAG_SYNC_REFRESH_DELETE, &cookie, 1, NULL, 0 );
}
rs->sr_ctrls = ctrls;
rs->sr_ref = rs->sr_v2ref;
rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
+ rs->sr_rspoid = NULL;
send_ldap_result( sop, rs );
if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) {
- ch_free( ctrls[num_ctrls-1]->ldctl_value.bv_val );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, sop->o_tmpmemctx );
}
- ch_free( ctrls[--num_ctrls] );
+ sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
if ( cookie.bv_val )
ch_free( cookie.bv_val );
rs->sr_ctrls = NULL;
rs->sr_ref = rs->sr_v2ref;
rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
+ rs->sr_rspoid = NULL;
send_ldap_result( sop, rs );
}
}
struct berval entryuuid_bv = { 0, NULL };
ber_init2( ber, 0, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
- ctrls[num_ctrls] = ch_malloc ( sizeof ( LDAPControl ) );
+ ctrls[num_ctrls] = sl_malloc ( sizeof ( LDAPControl ), op->o_tmpmemctx );
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
AttributeDescription *desc = a->a_desc;
BerElement *ber = (BerElement *)&berbuf;
ber_init2( ber, NULL, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
ctrls[num_ctrls] = ch_malloc ( sizeof ( LDAPControl ) );
struct berval entryuuid_bv = { 0, NULL };
- ber_init2( ber, 0, LBER_USE_DER );
+ ber_init2( ber, NULL, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
ctrls[num_ctrls] = ch_malloc ( sizeof ( LDAPControl ) );
int ret;
ber_init2( ber, NULL, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
if ( type ) {
switch ( type ) {
return new;
}
+
+int
+slap_build_syncUUID_set(
+ Operation *op,
+ BerVarray *set,
+ Entry *e
+)
+{
+ int ret;
+ Attribute* a;
+
+ struct berval entryuuid_bv = { 0, NULL };
+
+ for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+ AttributeDescription *desc = a->a_desc;
+ if ( desc == slap_schema.si_ad_entryUUID ) {
+ ber_dupbv_x( &entryuuid_bv, &a->a_nvals[0], op->o_tmpmemctx );
+ }
+ }
+
+ ret = ber_bvarray_add_x( set, &entryuuid_bv, op->o_tmpmemctx );
+
+ return ret;
+}
struct sync_cookie * ));
LDAP_SLAPD_F (struct sync_cookie *) slap_dup_sync_cookie LDAP_P((
struct sync_cookie *, struct sync_cookie * ));
+LDAP_SLAPD_F (int) slap_build_syncUUID_set LDAP_P((
+ Operation *, BerVarray *, Entry * ));
/*
* limits.c
rs->sr_attrs = uuid_attr;
rs->sr_ctrls = ctrls;
result = send_search_entry( op, rs );
- ch_free( ctrls[num_ctrls-1]->ldctl_value.bv_val );
- ch_free( ctrls[--num_ctrls] );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, op->o_tmpmemctx );
+ sl_free( ctrls[--num_ctrls], op->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
}
*/
#define SLAP_SYNC_SID_SIZE 3
+#define SLAP_SYNCUUID_SET_SIZE 256
struct nonpresent_entry {
struct berval *npe_name;
static const struct berval slap_syncrepl_bvc = BER_BVC(SYNCREPL_STR);
static const struct berval slap_syncrepl_cn_bvc = BER_BVC(CN_STR SYNCREPL_STR);
+static int syncuuid_cmp( const void *, const void * );
static void avl_ber_bvfree( void * );
-
-static void
-syncrepl_del_nonpresent( Operation *, syncinfo_t * );
+static void syncrepl_del_nonpresent( Operation *, syncinfo_t * );
/* callback functions */
static int dn_callback( struct slap_op *, struct slap_rep * );
struct sync_cookie syncCookie_req = { NULL, -1, NULL };
struct berval cookie = { 0, NULL };
- int rc;
- int err;
+ int rc, err, i;
ber_len_t len;
slap_callback cb;
int refreshDeletes = 0;
int refreshDone = 1;
- BerVarray syncUUIDs;
+ BerVarray syncUUIDs = NULL;
ber_tag_t si_tag;
if ( slapd_abrupt_shutdown ) {
goto done;
}
+ ber_init2( ber, NULL, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
+
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, DETAIL1, "do_syncrep2\n", 0, 0, 0 );
#else
ber_scanf( ber, "}" );
break;
case LDAP_TAG_SYNC_ID_SET:
- /* FIXME : to be supported */
ber_scanf( ber, "t{", &tag );
- if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
- {
+ if ( ber_peek_tag( ber, &len ) ==
+ LDAP_TAG_SYNC_COOKIE ) {
ber_scanf( ber, "m", &cookie );
if ( cookie.bv_val ) {
struct berval tmp_bv;
ber_dupbv( &tmp_bv, &cookie );
- ber_bvarray_add( &syncCookie.octet_str, &tmp_bv);
+ ber_bvarray_add( &syncCookie.octet_str,
+ &tmp_bv );
}
if ( syncCookie.octet_str &&
syncCookie.octet_str[0].bv_val )
}
ber_scanf( ber, "[W]", &syncUUIDs );
ber_scanf( ber, "}" );
+ for ( i = 0; syncUUIDs[i].bv_val; i++ ) {
+ struct berval *syncuuid_bv;
+ syncuuid_bv = ber_dupbv( NULL, &syncUUIDs[i] );
+ avl_insert( &si->si_presentlist,
+ (caddr_t) syncuuid_bv,
+ syncuuid_cmp, avl_dup_error );
+ }
+ ber_memfree_x( syncUUIDs, op->o_tmpmemctx );
break;
default:
#ifdef NEW_LOGGING
sl_free( ndn.bv_val, op->o_tmpmemctx );
sl_free( dn.bv_val, op->o_tmpmemctx );
- if ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_DELETE ) {
+ if ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_DELETE )
+ {
return NULL;
}
return e;
}
-int
-syncuuid_cmp( const void* v_uuid1, const void* v_uuid2 )
-{
- const struct berval *uuid1 = v_uuid1;
- const struct berval *uuid2 = v_uuid2;
- int rc = uuid1->bv_len - uuid2->bv_len;
- if ( rc ) return rc;
- return ( strcmp( uuid1->bv_val, uuid2->bv_val ) );
-}
-
int
syncrepl_entry(
syncinfo_t* si,
return new;
}
+static int
+syncuuid_cmp( const void* v_uuid1, const void* v_uuid2 )
+{
+ const struct berval *uuid1 = v_uuid1;
+ const struct berval *uuid2 = v_uuid2;
+ int rc = uuid1->bv_len - uuid2->bv_len;
+ if ( rc ) return rc;
+ return ( strcmp( uuid1->bv_val, uuid2->bv_val ) );
+}
+
static void
avl_ber_bvfree( void *bv )
{