1 /* modify.c - bdb backend modify routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2014 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
25 static struct berval scbva[] = {
33 AttributeDescription *desc,
41 /* check if modified attribute was indexed
42 * but not in case of NOOP... */
43 ai = bdb_index_mask( op->o_bd, desc, &ix_at );
49 ap = attr_find( oldattrs, desc );
50 if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
52 /* Find all other attrs that index to same slot */
53 for ( ap = newattrs; ap; ap = ap->a_next ) {
54 ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
55 if ( ai && ix2.bv_val == ix_at.bv_val )
56 ap->a_flags |= SLAP_ATTR_IXADD;
62 ap = attr_find( newattrs, desc );
63 if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
68 int bdb_modify_internal(
71 Modifications *modlist,
80 Attribute *save_attrs;
82 int glue_attr_delete = 0;
85 Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n",
88 if ( !acl_check_modlist( op, e, modlist )) {
89 return LDAP_INSUFFICIENT_ACCESS;
92 /* save_attrs will be disposed of by bdb_cache_modify */
93 save_attrs = e->e_attrs;
94 e->e_attrs = attrs_dup( e->e_attrs );
96 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
99 switch( mod->sm_op ) {
101 case LDAP_MOD_REPLACE:
102 if ( mod->sm_desc == slap_schema.si_ad_structuralObjectClass ) {
103 value_match( &match, slap_schema.si_ad_structuralObjectClass,
104 slap_schema.si_ad_structuralObjectClass->
105 ad_type->sat_equality,
106 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
107 &mod->sm_values[0], &scbva[0], text );
108 if ( !match ) glue_attr_delete = 1;
111 if ( glue_attr_delete )
115 if ( glue_attr_delete ) {
116 Attribute **app = &e->e_attrs;
117 while ( *app != NULL ) {
118 if ( !is_at_operational( (*app)->a_desc->ad_type )) {
119 Attribute *save = *app;
120 *app = (*app)->a_next;
124 app = &(*app)->a_next;
128 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
132 switch ( mod->sm_op ) {
134 Debug(LDAP_DEBUG_ARGS,
135 "bdb_modify_internal: add %s\n",
136 mod->sm_desc->ad_cname.bv_val, 0, 0);
137 err = modify_add_values( e, mod, get_permissiveModify(op),
138 text, textbuf, textlen );
139 if( err != LDAP_SUCCESS ) {
140 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
145 case LDAP_MOD_DELETE:
146 if ( glue_attr_delete ) {
151 Debug(LDAP_DEBUG_ARGS,
152 "bdb_modify_internal: delete %s\n",
153 mod->sm_desc->ad_cname.bv_val, 0, 0);
154 err = modify_delete_values( e, mod, get_permissiveModify(op),
155 text, textbuf, textlen );
156 if( err != LDAP_SUCCESS ) {
157 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
164 case LDAP_MOD_REPLACE:
165 Debug(LDAP_DEBUG_ARGS,
166 "bdb_modify_internal: replace %s\n",
167 mod->sm_desc->ad_cname.bv_val, 0, 0);
168 err = modify_replace_values( e, mod, get_permissiveModify(op),
169 text, textbuf, textlen );
170 if( err != LDAP_SUCCESS ) {
171 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
178 case LDAP_MOD_INCREMENT:
179 Debug(LDAP_DEBUG_ARGS,
180 "bdb_modify_internal: increment %s\n",
181 mod->sm_desc->ad_cname.bv_val, 0, 0);
182 err = modify_increment_values( e, mod, get_permissiveModify(op),
183 text, textbuf, textlen );
184 if( err != LDAP_SUCCESS ) {
185 Debug(LDAP_DEBUG_ARGS,
186 "bdb_modify_internal: %d %s\n",
193 case SLAP_MOD_SOFTADD:
194 Debug(LDAP_DEBUG_ARGS,
195 "bdb_modify_internal: softadd %s\n",
196 mod->sm_desc->ad_cname.bv_val, 0, 0);
197 /* Avoid problems in index_add_mods()
198 * We need to add index if necessary.
200 mod->sm_op = LDAP_MOD_ADD;
202 err = modify_add_values( e, mod, get_permissiveModify(op),
203 text, textbuf, textlen );
205 mod->sm_op = SLAP_MOD_SOFTADD;
207 if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) {
211 if( err != LDAP_SUCCESS ) {
212 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
217 case SLAP_MOD_SOFTDEL:
218 Debug(LDAP_DEBUG_ARGS,
219 "bdb_modify_internal: softdel %s\n",
220 mod->sm_desc->ad_cname.bv_val, 0, 0);
221 /* Avoid problems in index_delete_mods()
222 * We need to add index if necessary.
224 mod->sm_op = LDAP_MOD_DELETE;
226 err = modify_delete_values( e, mod, get_permissiveModify(op),
227 text, textbuf, textlen );
229 mod->sm_op = SLAP_MOD_SOFTDEL;
231 if ( err == LDAP_SUCCESS ) {
233 } else if ( err == LDAP_NO_SUCH_ATTRIBUTE ) {
237 if( err != LDAP_SUCCESS ) {
238 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
243 case SLAP_MOD_ADD_IF_NOT_PRESENT:
244 if ( attr_find( e->e_attrs, mod->sm_desc ) != NULL ) {
250 Debug(LDAP_DEBUG_ARGS,
251 "bdb_modify_internal: add_if_not_present %s\n",
252 mod->sm_desc->ad_cname.bv_val, 0, 0);
253 /* Avoid problems in index_add_mods()
254 * We need to add index if necessary.
256 mod->sm_op = LDAP_MOD_ADD;
258 err = modify_add_values( e, mod, get_permissiveModify(op),
259 text, textbuf, textlen );
261 mod->sm_op = SLAP_MOD_ADD_IF_NOT_PRESENT;
263 if( err != LDAP_SUCCESS ) {
264 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
270 Debug(LDAP_DEBUG_ANY, "bdb_modify_internal: invalid op %d\n",
272 *text = "Invalid modify operation";
274 Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
278 if ( err != LDAP_SUCCESS ) {
279 attrs_free( e->e_attrs );
280 e->e_attrs = save_attrs;
281 /* unlock entry, delete from cache */
285 /* If objectClass was modified, reset the flags */
286 if ( mod->sm_desc == slap_schema.si_ad_objectClass ) {
290 if ( glue_attr_delete ) e->e_ocflags = 0;
293 /* check if modified attribute was indexed
294 * but not in case of NOOP... */
296 bdb_modify_idxflags( op, mod->sm_desc, got_delete, e->e_attrs, save_attrs );
300 /* check that the entry still obeys the schema */
302 rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0, &ap,
303 text, textbuf, textlen );
304 if ( rc != LDAP_SUCCESS || op->o_noop ) {
305 attrs_free( e->e_attrs );
306 /* clear the indexing flags */
307 for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
308 ap->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
310 e->e_attrs = save_attrs;
312 if ( rc != LDAP_SUCCESS ) {
313 Debug( LDAP_DEBUG_ANY,
314 "entry failed schema check: %s\n",
318 /* if NOOP then silently revert to saved attrs */
322 /* structuralObjectClass modified! */
324 assert( ap->a_desc == slap_schema.si_ad_structuralObjectClass );
326 bdb_modify_idxflags( op, slap_schema.si_ad_structuralObjectClass,
327 1, e->e_attrs, save_attrs );
331 /* update the indices of the modified attributes */
333 /* start with deleting the old index entries */
334 for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
335 if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
338 ap->a_flags &= ~SLAP_ATTR_IXDEL;
339 a2 = attr_find( e->e_attrs, ap->a_desc );
341 /* need to detect which values were deleted */
343 /* let add know there were deletes */
344 if ( a2->a_flags & SLAP_ATTR_IXADD )
345 a2->a_flags |= SLAP_ATTR_IXDEL;
346 vals = op->o_tmpalloc( (ap->a_numvals + 1) *
347 sizeof(struct berval), op->o_tmpmemctx );
349 for ( i=0; i < ap->a_numvals; i++ ) {
350 rc = attr_valfind( a2, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
351 &ap->a_nvals[i], NULL, op->o_tmpmemctx );
352 /* Save deleted values */
353 if ( rc == LDAP_NO_SUCH_ATTRIBUTE )
354 vals[j++] = ap->a_nvals[i];
358 /* attribute was completely deleted */
362 if ( !BER_BVISNULL( vals )) {
363 rc = bdb_index_values( op, tid, ap->a_desc,
364 vals, e->e_id, SLAP_INDEX_DELETE_OP );
365 if ( rc != LDAP_SUCCESS ) {
366 Debug( LDAP_DEBUG_ANY,
367 "%s: attribute \"%s\" index delete failure\n",
368 op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
369 attrs_free( e->e_attrs );
370 e->e_attrs = save_attrs;
373 if ( vals != ap->a_nvals )
374 op->o_tmpfree( vals, op->o_tmpmemctx );
379 /* add the new index entries */
380 for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
381 if (ap->a_flags & SLAP_ATTR_IXADD) {
382 ap->a_flags &= ~SLAP_ATTR_IXADD;
383 if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
384 /* if any values were deleted, we must readd index
385 * for all remaining values.
387 ap->a_flags &= ~SLAP_ATTR_IXDEL;
388 rc = bdb_index_values( op, tid, ap->a_desc,
390 e->e_id, SLAP_INDEX_ADD_OP );
393 /* if this was only an add, we only need to index
396 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
398 if ( ml->sml_desc != ap->a_desc || !ml->sml_numvals )
401 switch( ml->sml_op ) {
403 case LDAP_MOD_REPLACE:
404 case LDAP_MOD_INCREMENT:
405 case SLAP_MOD_SOFTADD:
406 case SLAP_MOD_ADD_IF_NOT_PRESENT:
407 if ( ml->sml_op == LDAP_MOD_INCREMENT )
409 else if ( ml->sml_nvalues )
410 vals = ml->sml_nvalues;
412 vals = ml->sml_values;
413 rc = bdb_index_values( op, tid, ap->a_desc,
414 vals, e->e_id, SLAP_INDEX_ADD_OP );
420 /* This attr was affected by a modify of a subtype, so
421 * there was no direct match in the modlist. Just readd
425 rc = bdb_index_values( op, tid, ap->a_desc,
427 e->e_id, SLAP_INDEX_ADD_OP );
430 if ( rc != LDAP_SUCCESS ) {
431 Debug( LDAP_DEBUG_ANY,
432 "%s: attribute \"%s\" index add failure\n",
433 op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
434 attrs_free( e->e_attrs );
435 e->e_attrs = save_attrs;
446 bdb_modify( Operation *op, SlapReply *rs )
448 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
450 EntryInfo *ei = NULL;
451 int manageDSAit = get_manageDSAit( op );
452 char textbuf[SLAP_TEXT_BUFLEN];
453 size_t textlen = sizeof textbuf;
454 DB_TXN *ltid = NULL, *lt2;
455 struct bdb_op_info opinfo = {{{ 0 }}};
462 LDAPControl **preread_ctrl = NULL;
463 LDAPControl **postread_ctrl = NULL;
464 LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
473 Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(bdb_modify) ": %s\n",
474 op->o_req_dn.bv_val, 0, 0 );
477 if( op->o_txnSpec ) {
478 /* acquire connection lock */
479 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
480 if( op->o_conn->c_txn == CONN_TXN_INACTIVE ) {
481 rs->sr_text = "invalid transaction identifier";
482 rs->sr_err = LDAP_X_TXN_ID_INVALID;
484 } else if( op->o_conn->c_txn == CONN_TXN_SETTLE ) {
489 if( op->o_conn->c_txn_backend == NULL ) {
490 op->o_conn->c_txn_backend = op->o_bd;
492 } else if( op->o_conn->c_txn_backend != op->o_bd ) {
493 rs->sr_text = "transaction cannot span multiple database contexts";
494 rs->sr_err = LDAP_AFFECTS_MULTIPLE_DSAS;
498 /* insert operation into transaction */
500 rs->sr_text = "transaction specified";
501 rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;
504 /* release connection lock */
505 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
508 send_ldap_result( op, rs );
514 ctrls[num_ctrls] = NULL;
516 /* Don't touch the opattrs, if this is a contextCSN update
517 * initiated from updatedn */
518 if ( !be_isupdate(op) || !op->orm_modlist || op->orm_modlist->sml_next ||
519 op->orm_modlist->sml_desc != slap_schema.si_ad_contextCSN ) {
521 slap_mods_opattrs( op, &op->orm_modlist, 1 );
525 retry: /* transaction retry */
526 if ( dummy.e_attrs ) {
527 attrs_free( dummy.e_attrs );
528 dummy.e_attrs = NULL;
531 bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
534 Debug(LDAP_DEBUG_TRACE,
535 LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0);
537 rs->sr_err = TXN_ABORT( ltid );
539 LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
540 opinfo.boi_oe.oe_key = NULL;
541 op->o_do_not_cache = opinfo.boi_acl_cache;
542 if( rs->sr_err != 0 ) {
543 rs->sr_err = LDAP_OTHER;
544 rs->sr_text = "internal error";
547 if ( op->o_abandon ) {
548 rs->sr_err = SLAPD_ABANDON;
551 bdb_trans_backoff( ++num_retries );
554 /* begin transaction */
555 rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
556 bdb->bi_db_opflags );
558 if( rs->sr_err != 0 ) {
559 Debug( LDAP_DEBUG_TRACE,
560 LDAP_XSTRING(bdb_modify) ": txn_begin failed: "
561 "%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
562 rs->sr_err = LDAP_OTHER;
563 rs->sr_text = "internal error";
566 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modify) ": txn1 id: %x\n",
567 ltid->id(ltid), 0, 0 );
569 opinfo.boi_oe.oe_key = bdb;
570 opinfo.boi_txn = ltid;
572 opinfo.boi_acl_cache = op->o_do_not_cache;
573 LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
575 /* get entry or ancestor */
576 rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
579 if ( rs->sr_err != 0 ) {
580 Debug( LDAP_DEBUG_TRACE,
581 LDAP_XSTRING(bdb_modify) ": dn2entry failed (%d)\n",
583 switch( rs->sr_err ) {
584 case DB_LOCK_DEADLOCK:
585 case DB_LOCK_NOTGRANTED:
590 rs->sr_text = "ldap server busy";
593 rs->sr_err = LDAP_OTHER;
594 rs->sr_text = "internal error";
601 /* acquire and lock entry */
602 /* FIXME: dn2entry() should return non-glue entry */
603 if (( rs->sr_err == DB_NOTFOUND ) ||
604 ( !manageDSAit && e && is_entry_glue( e )))
607 rs->sr_matched = ch_strdup( e->e_dn );
608 rs->sr_ref = is_entry_referral( e )
609 ? get_entry_referrals( op, e )
611 bdb_unlocked_cache_return_entry_r (&bdb->bi_cache, e);
615 rs->sr_ref = referral_rewrite( default_referral, NULL,
616 &op->o_req_dn, LDAP_SCOPE_DEFAULT );
619 rs->sr_err = LDAP_REFERRAL;
620 send_ldap_result( op, rs );
622 if ( rs->sr_ref != default_referral ) {
623 ber_bvarray_free( rs->sr_ref );
625 free( (char *)rs->sr_matched );
627 rs->sr_matched = NULL;
632 if ( !manageDSAit && is_entry_referral( e ) ) {
633 /* entry is a referral, don't allow modify */
634 rs->sr_ref = get_entry_referrals( op, e );
636 Debug( LDAP_DEBUG_TRACE,
637 LDAP_XSTRING(bdb_modify) ": entry is referral\n",
640 rs->sr_err = LDAP_REFERRAL;
641 rs->sr_matched = e->e_name.bv_val;
642 send_ldap_result( op, rs );
644 ber_bvarray_free( rs->sr_ref );
646 rs->sr_matched = NULL;
650 if ( get_assert( op ) &&
651 ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
653 rs->sr_err = LDAP_ASSERTION_FAILED;
657 if( op->o_preread ) {
658 if( preread_ctrl == NULL ) {
659 preread_ctrl = &ctrls[num_ctrls++];
660 ctrls[num_ctrls] = NULL;
662 if ( slap_read_controls( op, rs, e,
663 &slap_pre_read_bv, preread_ctrl ) )
665 Debug( LDAP_DEBUG_TRACE,
666 "<=- " LDAP_XSTRING(bdb_modify) ": pre-read "
667 "failed!\n", 0, 0, 0 );
668 if ( op->o_preread & SLAP_CONTROL_CRITICAL ) {
669 /* FIXME: is it correct to abort
670 * operation if control fails? */
676 /* nested transaction */
677 rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, ltid, <2, bdb->bi_db_opflags );
679 if( rs->sr_err != 0 ) {
680 Debug( LDAP_DEBUG_TRACE,
681 LDAP_XSTRING(bdb_modify) ": txn_begin(2) failed: " "%s (%d)\n",
682 db_strerror(rs->sr_err), rs->sr_err, 0 );
683 rs->sr_err = LDAP_OTHER;
684 rs->sr_text = "internal error";
687 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modify) ": txn2 id: %x\n",
688 lt2->id(lt2), 0, 0 );
689 /* Modify the entry */
691 rs->sr_err = bdb_modify_internal( op, lt2, op->orm_modlist,
692 &dummy, &rs->sr_text, textbuf, textlen );
694 if( rs->sr_err != LDAP_SUCCESS ) {
695 Debug( LDAP_DEBUG_TRACE,
696 LDAP_XSTRING(bdb_modify) ": modify failed (%d)\n",
698 if ( (rs->sr_err == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) {
699 rs->sr_err = opinfo.boi_err;
701 /* Only free attrs if they were dup'd. */
702 if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
703 switch( rs->sr_err ) {
704 case DB_LOCK_DEADLOCK:
705 case DB_LOCK_NOTGRANTED:
711 /* change the entry itself */
712 rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy );
713 if ( rs->sr_err != 0 ) {
714 Debug( LDAP_DEBUG_TRACE,
715 LDAP_XSTRING(bdb_modify) ": id2entry update failed " "(%d)\n",
717 switch( rs->sr_err ) {
718 case DB_LOCK_DEADLOCK:
719 case DB_LOCK_NOTGRANTED:
722 rs->sr_text = "entry update failed";
726 if ( TXN_COMMIT( lt2, 0 ) != 0 ) {
727 rs->sr_err = LDAP_OTHER;
728 rs->sr_text = "txn_commit(2) failed";
732 if( op->o_postread ) {
733 if( postread_ctrl == NULL ) {
734 postread_ctrl = &ctrls[num_ctrls++];
735 ctrls[num_ctrls] = NULL;
737 if( slap_read_controls( op, rs, &dummy,
738 &slap_post_read_bv, postread_ctrl ) )
740 Debug( LDAP_DEBUG_TRACE,
741 "<=- " LDAP_XSTRING(bdb_modify)
742 ": post-read failed!\n", 0, 0, 0 );
743 if ( op->o_postread & SLAP_CONTROL_CRITICAL ) {
744 /* FIXME: is it correct to abort
745 * operation if control fails? */
752 if ( ( rs->sr_err = TXN_ABORT( ltid ) ) != 0 ) {
753 rs->sr_text = "txn_abort (no-op) failed";
755 rs->sr_err = LDAP_X_NO_OPERATION;
757 /* Only free attrs if they were dup'd. */
758 if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
762 /* may have changed in bdb_modify_internal() */
763 e->e_ocflags = dummy.e_ocflags;
764 rc = bdb_cache_modify( bdb, e, dummy.e_attrs, ltid, &lock );
766 case DB_LOCK_DEADLOCK:
767 case DB_LOCK_NOTGRANTED:
770 dummy.e_attrs = NULL;
772 rs->sr_err = TXN_COMMIT( ltid, 0 );
775 LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
776 opinfo.boi_oe.oe_key = NULL;
778 if( rs->sr_err != 0 ) {
779 Debug( LDAP_DEBUG_TRACE,
780 LDAP_XSTRING(bdb_modify) ": txn_%s failed: %s (%d)\n",
781 op->o_noop ? "abort (no-op)" : "commit",
782 db_strerror(rs->sr_err), rs->sr_err );
783 rs->sr_err = LDAP_OTHER;
784 rs->sr_text = "commit failed";
789 Debug( LDAP_DEBUG_TRACE,
790 LDAP_XSTRING(bdb_modify) ": updated%s id=%08lx dn=\"%s\"\n",
791 op->o_noop ? " (no-op)" : "",
792 dummy.e_id, op->o_req_dn.bv_val );
794 rs->sr_err = LDAP_SUCCESS;
796 if( num_ctrls ) rs->sr_ctrls = ctrls;
799 if( dummy.e_attrs ) {
800 attrs_free( dummy.e_attrs );
802 send_ldap_result( op, rs );
804 if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp_kbyte ) {
805 TXN_CHECKPOINT( bdb->bi_dbenv,
806 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
810 slap_graduate_commit_csn( op );
815 if ( opinfo.boi_oe.oe_key ) {
816 LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
820 bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
823 if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
824 slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
825 slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
827 if( postread_ctrl != NULL && (*postread_ctrl) != NULL ) {
828 slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
829 slap_sl_free( *postread_ctrl, op->o_tmpmemctx );