)
{
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_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;
#include "slap.h"
#include "lutil_ldap.h"
-struct berval *
-slap_get_commit_csn( Operation *op )
+const struct berval slap_ldapsync_bv = BER_BVC("ldapsync");
+const struct berval slap_ldapsync_cn_bv = BER_BVC("cn=ldapsync");
+
+void
+slap_get_commit_csn( Operation *op, struct berval *csn )
{
- struct berval *max_committed_csn = NULL;
struct slap_csn_entry *csne = NULL, *committed_csne = NULL;
int i = 0;
+ csn->bv_val = NULL;
+ csn->bv_len = 0;
+
ldap_pvt_thread_mutex_lock( &op->o_bd->be_pcl_mutex );
LDAP_TAILQ_FOREACH( csne, &op->o_bd->be_pending_csn_list, csn_link ) {
ldap_pvt_thread_mutex_unlock( &op->o_bd->be_pcl_mutex );
if ( committed_csne ) {
- max_committed_csn = ber_dupbv( NULL, committed_csne->csn );
+ ber_dupbv( csn, committed_csne->csn );
}
-
- return max_committed_csn;
}
void
attr_merge( e, slap_schema.si_ad_objectClass, ocbva, NULL );
- bv.bv_val = "subentry";
- bv.bv_len = sizeof("subentry")-1;
-
- attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &bv, NULL );
+ attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &ocbva[1], NULL );
attr_merge_one( e, slap_schema.si_ad_cn, &slap_ldapsync_bv, NULL );