mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
use of bdb_modify_internal() in bdb_csn_commit()
fix EntryInfo handling in bdb_csn_commit()
This commit is contained in:
parent
57152b08ce
commit
4cda6127ee
@ -504,6 +504,10 @@ retry: /* transaction retry */
|
|||||||
|
|
||||||
bdb_cache_add( bdb, ei, op->oq_add.rs_e, &nrdn, locker );
|
bdb_cache_add( bdb, ei, op->oq_add.rs_e, &nrdn, locker );
|
||||||
|
|
||||||
|
if ( suffix_ei == NULL ) {
|
||||||
|
suffix_ei = op->oq_add.rs_e->e_private;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !op->o_bd->syncinfo ) {
|
if ( !op->o_bd->syncinfo ) {
|
||||||
if ( ctxcsn_added ) {
|
if ( ctxcsn_added ) {
|
||||||
ctx_nrdn.bv_val = "cn=ldapsync";
|
ctx_nrdn.bv_val = "cn=ldapsync";
|
||||||
|
@ -46,12 +46,18 @@ bdb_csn_commit(
|
|||||||
struct berval ctxcsn_rdn = { 0, NULL };
|
struct berval ctxcsn_rdn = { 0, NULL };
|
||||||
struct berval ctxcsn_ndn = { 0, NULL };
|
struct berval ctxcsn_ndn = { 0, NULL };
|
||||||
EntryInfo *ctxcsn_ei = NULL;
|
EntryInfo *ctxcsn_ei = NULL;
|
||||||
|
EntryInfo eip;
|
||||||
DB_LOCK ctxcsn_lock;
|
DB_LOCK ctxcsn_lock;
|
||||||
struct berval *max_committed_csn = NULL;
|
struct berval *max_committed_csn = NULL;
|
||||||
DB_LOCK suffix_lock;
|
DB_LOCK suffix_lock;
|
||||||
int rc, ret;
|
int rc, ret;
|
||||||
ID ctxcsn_id;
|
ID ctxcsn_id;
|
||||||
Entry *e;
|
Entry *e;
|
||||||
|
char textbuf[SLAP_TEXT_BUFLEN];
|
||||||
|
size_t textlen = sizeof textbuf;
|
||||||
|
Modifications *ml, *mlnext, *mod, *modlist;
|
||||||
|
Modifications **modtail = &modlist;
|
||||||
|
struct berval *csnbva = NULL;
|
||||||
|
|
||||||
if ( ei ) {
|
if ( ei ) {
|
||||||
e = ei->bei_e;
|
e = ei->bei_e;
|
||||||
@ -83,9 +89,51 @@ bdb_csn_commit(
|
|||||||
ber_bvfree( max_committed_csn );
|
ber_bvfree( max_committed_csn );
|
||||||
return BDB_CSN_ABORT;
|
return BDB_CSN_ABORT;
|
||||||
} else {
|
} else {
|
||||||
attr_delete( &(*ctxcsn_e)->e_attrs, slap_schema.si_ad_contextCSN );
|
csnbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
|
||||||
attr_merge_normalize_one( *ctxcsn_e, slap_schema.si_ad_contextCSN,
|
ber_dupbv( &csnbva[0], max_committed_csn );
|
||||||
max_committed_csn, NULL );
|
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
|
||||||
|
mod->sml_op = LDAP_MOD_REPLACE;
|
||||||
|
ber_str2bv( "contextCSN", strlen("contextCSN"), 1, &mod->sml_type );
|
||||||
|
mod->sml_bvalues = csnbva;
|
||||||
|
*modtail = mod;
|
||||||
|
modtail = &mod->sml_next;
|
||||||
|
|
||||||
|
ret = slap_mods_check( modlist, 1, &rs->sr_text, textbuf, textlen, NULL );
|
||||||
|
|
||||||
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG( OPERATION, ERR,
|
||||||
|
"bdb_csn_commit: mods check (%s)\n", rs->sr_text, 0, 0 );
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"bdb_csn_commit: mods check (%s)\n", rs->sr_text, 0, 0 );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = bdb_modify_internal( op, tid, modlist, *ctxcsn_e,
|
||||||
|
&rs->sr_text, textbuf, textlen );
|
||||||
|
if ( ret != LDAP_SUCCESS ) {
|
||||||
|
#ifdef NEW_LOGGING
|
||||||
|
LDAP_LOG ( OPERATION, ERR,
|
||||||
|
"bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 );
|
||||||
|
#else
|
||||||
|
Debug( LDAP_DEBUG_TRACE,
|
||||||
|
"bdb_csn_commit: modify failed (%d)\n", rs->sr_err, 0, 0 );
|
||||||
|
#endif
|
||||||
|
switch( ret ) {
|
||||||
|
case DB_LOCK_DEADLOCK:
|
||||||
|
case DB_LOCK_NOTGRANTED:
|
||||||
|
return BDB_CSN_ABORT;
|
||||||
|
default:
|
||||||
|
goto rewind;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ml = modlist; ml != NULL; ml = mlnext ) {
|
||||||
|
mlnext = ml->sml_next;
|
||||||
|
free( ml );
|
||||||
|
}
|
||||||
|
|
||||||
ret = bdb_id2entry_update( op->o_bd, tid, *ctxcsn_e );
|
ret = bdb_id2entry_update( op->o_bd, tid, *ctxcsn_e );
|
||||||
switch ( ret ) {
|
switch ( ret ) {
|
||||||
case 0 :
|
case 0 :
|
||||||
@ -98,29 +146,27 @@ bdb_csn_commit(
|
|||||||
rs->sr_text = "context csn update failed";
|
rs->sr_text = "context csn update failed";
|
||||||
return BDB_CSN_ABORT;
|
return BDB_CSN_ABORT;
|
||||||
}
|
}
|
||||||
ret = bdb_index_entry_add( op, tid, *ctxcsn_e );
|
|
||||||
switch ( ret ) {
|
|
||||||
case 0 :
|
|
||||||
break;
|
|
||||||
case DB_LOCK_DEADLOCK :
|
|
||||||
case DB_LOCK_NOTGRANTED :
|
|
||||||
goto rewind;
|
|
||||||
default :
|
|
||||||
rs->sr_err = LDAP_OTHER;
|
|
||||||
rs->sr_text = "context csn indexing failed";
|
|
||||||
return BDB_CSN_ABORT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DB_NOTFOUND:
|
case DB_NOTFOUND:
|
||||||
if ( op->o_tag == LDAP_REQ_ADD && !be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname )) {
|
if ( op->o_tag == LDAP_REQ_ADD ) {
|
||||||
|
if ( !be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname )) {
|
||||||
rc = bdb_dn2entry( op, tid, &op->o_bd->be_nsuffix[0], suffix_ei,
|
rc = bdb_dn2entry( op, tid, &op->o_bd->be_nsuffix[0], suffix_ei,
|
||||||
0, locker, &suffix_lock );
|
0, locker, &suffix_lock );
|
||||||
} else if ( op->o_tag != LDAP_REQ_ADD && !be_issuffix( op->o_bd, &e->e_nname )) {
|
eip.bei_id = (*suffix_ei)->bei_id;
|
||||||
|
} else {
|
||||||
|
*suffix_ei = NULL;
|
||||||
|
eip.bei_id = op->oq_add.rs_e->e_id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( !be_issuffix( op->o_bd, &e->e_nname )) {
|
||||||
rc = bdb_dn2entry( op, tid, &op->o_bd->be_nsuffix[0], suffix_ei,
|
rc = bdb_dn2entry( op, tid, &op->o_bd->be_nsuffix[0], suffix_ei,
|
||||||
0, locker, &suffix_lock );
|
0, locker, &suffix_lock );
|
||||||
|
eip.bei_id = (*suffix_ei)->bei_id;
|
||||||
} else {
|
} else {
|
||||||
*suffix_ei = ei;
|
*suffix_ei = ei;
|
||||||
|
eip.bei_id = e->e_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This serializes add. But this case is very rare : only once. */
|
/* This serializes add. But this case is very rare : only once. */
|
||||||
@ -142,7 +188,8 @@ bdb_csn_commit(
|
|||||||
ber_bvfree( max_committed_csn );
|
ber_bvfree( max_committed_csn );
|
||||||
(*ctxcsn_e)->e_id = ctxcsn_id;
|
(*ctxcsn_e)->e_id = ctxcsn_id;
|
||||||
*ctxcsn_added = 1;
|
*ctxcsn_added = 1;
|
||||||
ret = bdb_dn2id_add( op, tid, *suffix_ei, *ctxcsn_e );
|
|
||||||
|
ret = bdb_dn2id_add( op, tid, &eip, *ctxcsn_e );
|
||||||
switch ( ret ) {
|
switch ( ret ) {
|
||||||
case 0 :
|
case 0 :
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user