+ if ( !dn_match( &ctxcsn_ndn, &op->o_req_ndn ) &&
+ !be_issuffix( op->o_bd, &op->o_req_ndn ) &&
+ LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+ rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
+ &ctxcsn_e, &ctxcsn_added, locker );
+ switch ( rc ) {
+ case BDB_CSN_ABORT :
+ goto return_results;
+ case BDB_CSN_RETRY :
+ goto retry;
+ }
+ }
+
+ if( op->o_noop ) {
+ if ( ( rs->sr_err = TXN_ABORT( ltid ) ) != 0 ) {
+ rs->sr_text = "txn_abort (no-op) failed";
+ } else {
+ rs->sr_err = LDAP_NO_OPERATION;
+ goto return_results;
+ }
+ } else {
+ rc = bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv,
+ locker, &lock );
+ switch( rc ) {
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ }
+
+ if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+ if ( ctxcsn_added ) {
+ bdb_cache_add( bdb, suffix_ei,
+ ctxcsn_e, (struct berval *)&slap_ldapsync_cn_bv, locker );
+ }
+ }
+
+ if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) {
+ Attribute *a;
+ a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
+ if ( a ) {
+ if( (void *) e->e_attrs != (void *) (e+1)) {
+ attr_delete( &e->e_attrs, slap_schema.si_ad_entryCSN );
+ attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN,
+ &op->o_sync_csn, NULL );
+ } else {
+ a->a_vals[0] = op->o_sync_csn;
+ }
+ } else {
+ /* Hm, the entryCSN ought to exist. ??? */
+ }
+ ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
+ LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+ rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE );
+ if ( rc ) {
+ Debug( LDAP_DEBUG_TRACE,
+ LDAP_XSTRING(bdb_delete)
+ ": persistent search failed "
+ "(%d,%d)\n",
+ rc, rs->sr_err, 0 );
+ }
+ }
+ ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
+ }
+
+ rs->sr_err = TXN_COMMIT( ltid, 0 );