)
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
- struct berval ctxcsn_ndn = { 0, NULL };
EntryInfo *ctxcsn_ei = NULL;
DB_LOCK ctxcsn_lock;
- struct berval *max_committed_csn = NULL;
+ struct berval max_committed_csn;
DB_LOCK suffix_lock;
int rc, ret;
ID ctxcsn_id;
e = ei->bei_e;
}
- build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0],
- (struct berval *)&slap_ldapsync_cn_bv );
-
- rc = bdb_dn2entry( op, tid, &ctxcsn_ndn, &ctxcsn_ei,
- 1, locker, &ctxcsn_lock );
-
- *ctxcsn_e = ctxcsn_ei->bei_e;
+ bdb_cache_find_ndn( op, tid, op->o_bd->be_nsuffix, &ctxcsn_ei );
+ bdb_cache_entryinfo_unlock( ctxcsn_ei );
+ rc = bdb_cache_find_ndn( op, tid, &slap_ldapsync_cn_bv, &ctxcsn_ei );
+ if ( rc == 0 ) {
+ rc = bdb_cache_find_id( op, tid, ctxcsn_ei->bei_id, &ctxcsn_ei, 1,
+ locker, &ctxcsn_lock );
+ *ctxcsn_e = ctxcsn_ei->bei_e;
+ } else {
+ bdb_cache_entryinfo_unlock( ctxcsn_ei );
+ }
- max_committed_csn = slap_get_commit_csn( op );
+ slap_get_commit_csn( op, &max_committed_csn );
- if ( max_committed_csn == NULL ) {
+ if ( max_committed_csn.bv_val == NULL ) {
return BDB_CSN_COMMIT;
}
if ( !*ctxcsn_e ) {
rs->sr_err = LDAP_OTHER;
rs->sr_text = "context csn not present";
- ber_bvfree( max_committed_csn );
+ ch_free( max_committed_csn.bv_val );
return BDB_CSN_ABORT;
} else {
Modifications mod;
struct berval modvals[2];
+ Entry dummy;
- modvals[0] = *max_committed_csn;
+ modvals[0] = max_committed_csn;
modvals[1].bv_val = NULL;
modvals[1].bv_len = 0;
mod.sml_op = LDAP_MOD_REPLACE;
mod.sml_bvalues = modvals;
+ mod.sml_nvalues = NULL;
mod.sml_desc = slap_schema.si_ad_contextCSN;
mod.sml_type = mod.sml_desc->ad_cname;
mod.sml_next = NULL;
- bdb_cache_entry_db_relock( bdb->bi_dbenv, locker, ctxcsn_ei, 1, 0, &ctxcsn_lock );
-
- ret = bdb_modify_internal( op, tid, &mod, *ctxcsn_e,
- &rs->sr_text, textbuf, textlen );
- ber_bvfree( max_committed_csn );
+ dummy = **ctxcsn_e;
+ ret = bdb_modify_internal( op, tid, &mod, &dummy,
+ &rs->sr_text, textbuf, textlen );
+ ch_free( max_committed_csn.bv_val );
if ( ret != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
}
}
- ret = bdb_id2entry_update( op->o_bd, tid, *ctxcsn_e );
+ ret = bdb_id2entry_update( op->o_bd, tid, &dummy );
switch ( ret ) {
case 0 :
break;
rs->sr_text = "context csn update failed";
return BDB_CSN_ABORT;
}
+ bdb_cache_modify( *ctxcsn_e, dummy.e_attrs, bdb->bi_dbenv, locker, &ctxcsn_lock );
}
break;
case DB_NOTFOUND:
return BDB_CSN_ABORT;
}
- *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, max_committed_csn );
- ber_bvfree( max_committed_csn );
+ *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, &max_committed_csn );
+ ch_free( max_committed_csn.bv_val );
(*ctxcsn_e)->e_id = ctxcsn_id;
*ctxcsn_added = 1;
)
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
- struct berval ctxcsn_rdn = BER_BVNULL;
struct berval ctxcsn_ndn = BER_BVNULL;
struct berval csn = BER_BVNULL;
- struct berval ctx_nrdn = BER_BVC( "cn=ldapsync" );
EntryInfo *ctxcsn_ei = NULL;
EntryInfo *suffix_ei = NULL;
Entry *ctxcsn_e = NULL;
DB_TXN *ltid = NULL;
Attribute *csn_a;
- char substr[67];
char gid[DB_XIDDATASIZE];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
int num_retries = 0;
if ( op->o_sync_mode != SLAP_SYNC_NONE ) {
if ( op->o_bd->syncinfo ) {
+ char substr[67];
+ struct berval bv;
sprintf( substr, "cn=syncrepl%d", op->o_bd->syncinfo->id );
- ber_str2bv( substr, strlen( substr ), 0, &ctxcsn_rdn );
- build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &ctxcsn_rdn );
+ ber_str2bv( substr, 0, 0, &bv );
+ build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &bv );
} else {
- ber_str2bv( "cn=ldapsync", strlen("cn=ldapsync"), 0, &ctxcsn_rdn );
- build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &ctxcsn_rdn );
+ build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], (struct berval *)&slap_ldapsync_cn_bv );
}
ctxcsn_retry :
return rs->sr_err;
}
- bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+ bdb_cache_add( bdb, suffix_ei, ctxcsn_e, (struct berval *)&slap_ldapsync_cn_bv, locker );
rs->sr_err = TXN_COMMIT( ltid, 0 );
if ( rs->sr_err != 0 ) {