mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
ITS#5225 fix contextCSN updating
This commit is contained in:
parent
9602d401a5
commit
f8588ff0c3
@ -746,17 +746,21 @@ ID bdb_tool_entry_modify(
|
||||
(long) e->e_id, e->e_dn, 0 );
|
||||
|
||||
if (! (slapMode & SLAP_TOOL_QUICK)) {
|
||||
rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid,
|
||||
bdb->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_begin failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
return NOID;
|
||||
}
|
||||
if( cursor ) {
|
||||
cursor->c_close( cursor );
|
||||
cursor = NULL;
|
||||
}
|
||||
rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid,
|
||||
bdb->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_begin failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
return NOID;
|
||||
}
|
||||
}
|
||||
|
||||
op.o_hdr = &ohdr;
|
||||
|
@ -353,10 +353,13 @@ slapadd( int argc, char **argv )
|
||||
ctxcsn_e = be->be_entry_get( be, ctxcsn_id );
|
||||
if ( ctxcsn_e != NULL ) {
|
||||
Entry *e = entry_dup( ctxcsn_e );
|
||||
int change;
|
||||
attr = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
|
||||
if ( attr ) {
|
||||
int i;
|
||||
|
||||
change = 0;
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &attr->a_nvals[ i ] ); i++ ) {
|
||||
int rc_sid;
|
||||
|
||||
@ -384,7 +387,9 @@ slapadd( int argc, char **argv )
|
||||
&maxcsn[ sid ], &attr->a_nvals[i], &text );
|
||||
}
|
||||
|
||||
if ( match < 0 ) {
|
||||
if ( match > 0 ) {
|
||||
change = 1;
|
||||
} else {
|
||||
AC_MEMCPY( maxcsn[ sid ].bv_val,
|
||||
attr->a_nvals[ i ].bv_val,
|
||||
attr->a_nvals[ i ].bv_len );
|
||||
@ -393,29 +398,36 @@ slapadd( int argc, char **argv )
|
||||
}
|
||||
}
|
||||
|
||||
if ( attr->a_nvals != attr->a_nvals ) {
|
||||
ber_bvarray_free( attr->a_nvals );
|
||||
if ( change ) {
|
||||
if ( attr->a_nvals != attr->a_vals ) {
|
||||
ber_bvarray_free( attr->a_nvals );
|
||||
}
|
||||
attr->a_nvals = NULL;
|
||||
ber_bvarray_free( attr->a_vals );
|
||||
attr->a_vals = NULL;
|
||||
attr->a_numvals = 0;
|
||||
}
|
||||
attr->a_nvals = NULL;
|
||||
ber_bvarray_free( attr->a_vals );
|
||||
attr->a_vals = NULL;
|
||||
} else {
|
||||
change = 1;
|
||||
}
|
||||
|
||||
for ( sid = 0; sid <= SLAP_SYNC_SID_MAX; sid++ ) {
|
||||
if ( maxcsn[ sid ].bv_len ) {
|
||||
attr_merge_one( e, slap_schema.si_ad_contextCSN,
|
||||
&maxcsn[ sid], NULL );
|
||||
if ( change ) {
|
||||
for ( sid = 0; sid <= SLAP_SYNC_SID_MAX; sid++ ) {
|
||||
if ( maxcsn[ sid ].bv_len ) {
|
||||
attr_merge_one( e, slap_schema.si_ad_contextCSN,
|
||||
&maxcsn[ sid], NULL );
|
||||
}
|
||||
}
|
||||
|
||||
ctxcsn_id = be->be_entry_modify( be, e, &bvtext );
|
||||
if( ctxcsn_id == NOID ) {
|
||||
fprintf( stderr, "%s: could not modify ctxcsn\n",
|
||||
progname);
|
||||
rc = EXIT_FAILURE;
|
||||
} else if ( verbose ) {
|
||||
fprintf( stderr, "modified: \"%s\" (%08lx)\n",
|
||||
e->e_dn, (long) ctxcsn_id );
|
||||
}
|
||||
}
|
||||
|
||||
ctxcsn_id = be->be_entry_modify( be, e, &bvtext );
|
||||
if( ctxcsn_id == NOID ) {
|
||||
fprintf( stderr, "%s: could not modify ctxcsn\n",
|
||||
progname);
|
||||
rc = EXIT_FAILURE;
|
||||
} else if ( verbose ) {
|
||||
fprintf( stderr, "modified: \"%s\" (%08lx)\n",
|
||||
e->e_dn, (long) ctxcsn_id );
|
||||
}
|
||||
entry_free( e );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user