delete.c revision 1.1 1 1.1 tron /* $NetBSD: delete.c,v 1.1 2014/05/28 09:58:49 tron Exp $ */
2 1.1 tron
3 1.1 tron /* delete.c - mdb backend delete routine */
4 1.1 tron /* $OpenLDAP$ */
5 1.1 tron /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6 1.1 tron *
7 1.1 tron * Copyright 2000-2014 The OpenLDAP Foundation.
8 1.1 tron * All rights reserved.
9 1.1 tron *
10 1.1 tron * Redistribution and use in source and binary forms, with or without
11 1.1 tron * modification, are permitted only as authorized by the OpenLDAP
12 1.1 tron * Public License.
13 1.1 tron *
14 1.1 tron * A copy of this license is available in the file LICENSE in the
15 1.1 tron * top-level directory of the distribution or, alternatively, at
16 1.1 tron * <http://www.OpenLDAP.org/license.html>.
17 1.1 tron */
18 1.1 tron
19 1.1 tron #include "portable.h"
20 1.1 tron
21 1.1 tron #include <stdio.h>
22 1.1 tron #include <ac/string.h>
23 1.1 tron
24 1.1 tron #include "lutil.h"
25 1.1 tron #include "back-mdb.h"
26 1.1 tron
27 1.1 tron int
28 1.1 tron mdb_delete( Operation *op, SlapReply *rs )
29 1.1 tron {
30 1.1 tron struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
31 1.1 tron struct berval pdn = {0, NULL};
32 1.1 tron Entry *e = NULL;
33 1.1 tron Entry *p = NULL;
34 1.1 tron int manageDSAit = get_manageDSAit( op );
35 1.1 tron AttributeDescription *children = slap_schema.si_ad_children;
36 1.1 tron AttributeDescription *entry = slap_schema.si_ad_entry;
37 1.1 tron MDB_txn *txn = NULL;
38 1.1 tron MDB_cursor *mc;
39 1.1 tron mdb_op_info opinfo = {{{ 0 }}}, *moi = &opinfo;
40 1.1 tron
41 1.1 tron LDAPControl **preread_ctrl = NULL;
42 1.1 tron LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
43 1.1 tron int num_ctrls = 0;
44 1.1 tron
45 1.1 tron int parent_is_glue = 0;
46 1.1 tron int parent_is_leaf = 0;
47 1.1 tron
48 1.1 tron #ifdef LDAP_X_TXN
49 1.1 tron int settle = 0;
50 1.1 tron #endif
51 1.1 tron
52 1.1 tron Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_delete) ": %s\n",
53 1.1 tron op->o_req_dn.bv_val, 0, 0 );
54 1.1 tron
55 1.1 tron #ifdef LDAP_X_TXN
56 1.1 tron if( op->o_txnSpec ) {
57 1.1 tron /* acquire connection lock */
58 1.1 tron ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
59 1.1 tron if( op->o_conn->c_txn == CONN_TXN_INACTIVE ) {
60 1.1 tron rs->sr_text = "invalid transaction identifier";
61 1.1 tron rs->sr_err = LDAP_X_TXN_ID_INVALID;
62 1.1 tron goto txnReturn;
63 1.1 tron } else if( op->o_conn->c_txn == CONN_TXN_SETTLE ) {
64 1.1 tron settle=1;
65 1.1 tron goto txnReturn;
66 1.1 tron }
67 1.1 tron
68 1.1 tron if( op->o_conn->c_txn_backend == NULL ) {
69 1.1 tron op->o_conn->c_txn_backend = op->o_bd;
70 1.1 tron
71 1.1 tron } else if( op->o_conn->c_txn_backend != op->o_bd ) {
72 1.1 tron rs->sr_text = "transaction cannot span multiple database contexts";
73 1.1 tron rs->sr_err = LDAP_AFFECTS_MULTIPLE_DSAS;
74 1.1 tron goto txnReturn;
75 1.1 tron }
76 1.1 tron
77 1.1 tron /* insert operation into transaction */
78 1.1 tron
79 1.1 tron rs->sr_text = "transaction specified";
80 1.1 tron rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;
81 1.1 tron
82 1.1 tron txnReturn:
83 1.1 tron /* release connection lock */
84 1.1 tron ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
85 1.1 tron
86 1.1 tron if( !settle ) {
87 1.1 tron send_ldap_result( op, rs );
88 1.1 tron return rs->sr_err;
89 1.1 tron }
90 1.1 tron }
91 1.1 tron #endif
92 1.1 tron
93 1.1 tron ctrls[num_ctrls] = 0;
94 1.1 tron
95 1.1 tron /* begin transaction */
96 1.1 tron rs->sr_err = mdb_opinfo_get( op, mdb, 0, &moi );
97 1.1 tron rs->sr_text = NULL;
98 1.1 tron if( rs->sr_err != 0 ) {
99 1.1 tron Debug( LDAP_DEBUG_TRACE,
100 1.1 tron LDAP_XSTRING(mdb_delete) ": txn_begin failed: "
101 1.1 tron "%s (%d)\n", mdb_strerror(rs->sr_err), rs->sr_err, 0 );
102 1.1 tron rs->sr_err = LDAP_OTHER;
103 1.1 tron rs->sr_text = "internal error";
104 1.1 tron goto return_results;
105 1.1 tron }
106 1.1 tron txn = moi->moi_txn;
107 1.1 tron
108 1.1 tron /* allocate CSN */
109 1.1 tron if ( BER_BVISNULL( &op->o_csn ) ) {
110 1.1 tron struct berval csn;
111 1.1 tron char csnbuf[LDAP_PVT_CSNSTR_BUFSIZE];
112 1.1 tron
113 1.1 tron csn.bv_val = csnbuf;
114 1.1 tron csn.bv_len = sizeof(csnbuf);
115 1.1 tron slap_get_csn( op, &csn, 1 );
116 1.1 tron }
117 1.1 tron
118 1.1 tron if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
119 1.1 tron dnParent( &op->o_req_ndn, &pdn );
120 1.1 tron }
121 1.1 tron
122 1.1 tron rs->sr_err = mdb_cursor_open( txn, mdb->mi_dn2id, &mc );
123 1.1 tron if ( rs->sr_err ) {
124 1.1 tron rs->sr_err = LDAP_OTHER;
125 1.1 tron rs->sr_text = "internal error";
126 1.1 tron goto return_results;
127 1.1 tron }
128 1.1 tron /* get parent */
129 1.1 tron rs->sr_err = mdb_dn2entry( op, txn, mc, &pdn, &p, NULL, 1 );
130 1.1 tron switch( rs->sr_err ) {
131 1.1 tron case 0:
132 1.1 tron case MDB_NOTFOUND:
133 1.1 tron break;
134 1.1 tron case LDAP_BUSY:
135 1.1 tron rs->sr_text = "ldap server busy";
136 1.1 tron goto return_results;
137 1.1 tron default:
138 1.1 tron rs->sr_err = LDAP_OTHER;
139 1.1 tron rs->sr_text = "internal error";
140 1.1 tron goto return_results;
141 1.1 tron }
142 1.1 tron if ( rs->sr_err == MDB_NOTFOUND ) {
143 1.1 tron Debug( LDAP_DEBUG_ARGS,
144 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": no such object %s\n",
145 1.1 tron op->o_req_dn.bv_val, 0, 0);
146 1.1 tron
147 1.1 tron if ( p && !BER_BVISEMPTY( &p->e_name )) {
148 1.1 tron rs->sr_matched = ch_strdup( p->e_name.bv_val );
149 1.1 tron if ( is_entry_referral( p )) {
150 1.1 tron BerVarray ref = get_entry_referrals( op, p );
151 1.1 tron rs->sr_ref = referral_rewrite( ref, &p->e_name,
152 1.1 tron &op->o_req_dn, LDAP_SCOPE_DEFAULT );
153 1.1 tron ber_bvarray_free( ref );
154 1.1 tron } else {
155 1.1 tron rs->sr_ref = NULL;
156 1.1 tron }
157 1.1 tron } else {
158 1.1 tron rs->sr_ref = referral_rewrite( default_referral, NULL,
159 1.1 tron &op->o_req_dn, LDAP_SCOPE_DEFAULT );
160 1.1 tron }
161 1.1 tron if ( p ) {
162 1.1 tron mdb_entry_return( op, p );
163 1.1 tron p = NULL;
164 1.1 tron }
165 1.1 tron
166 1.1 tron rs->sr_err = LDAP_REFERRAL;
167 1.1 tron rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
168 1.1 tron goto return_results;
169 1.1 tron }
170 1.1 tron
171 1.1 tron /* get entry */
172 1.1 tron rs->sr_err = mdb_dn2entry( op, txn, mc, &op->o_req_ndn, &e, NULL, 0 );
173 1.1 tron switch( rs->sr_err ) {
174 1.1 tron case MDB_NOTFOUND:
175 1.1 tron e = p;
176 1.1 tron p = NULL;
177 1.1 tron case 0:
178 1.1 tron break;
179 1.1 tron case LDAP_BUSY:
180 1.1 tron rs->sr_text = "ldap server busy";
181 1.1 tron goto return_results;
182 1.1 tron default:
183 1.1 tron rs->sr_err = LDAP_OTHER;
184 1.1 tron rs->sr_text = "internal error";
185 1.1 tron goto return_results;
186 1.1 tron }
187 1.1 tron
188 1.1 tron /* FIXME : dn2entry() should return non-glue entry */
189 1.1 tron if ( rs->sr_err == MDB_NOTFOUND || ( !manageDSAit && is_entry_glue( e ))) {
190 1.1 tron Debug( LDAP_DEBUG_ARGS,
191 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": no such object %s\n",
192 1.1 tron op->o_req_dn.bv_val, 0, 0);
193 1.1 tron
194 1.1 tron rs->sr_matched = ch_strdup( e->e_dn );
195 1.1 tron if ( is_entry_referral( e )) {
196 1.1 tron BerVarray ref = get_entry_referrals( op, e );
197 1.1 tron rs->sr_ref = referral_rewrite( ref, &e->e_name,
198 1.1 tron &op->o_req_dn, LDAP_SCOPE_DEFAULT );
199 1.1 tron ber_bvarray_free( ref );
200 1.1 tron } else {
201 1.1 tron rs->sr_ref = NULL;
202 1.1 tron }
203 1.1 tron mdb_entry_return( op, e );
204 1.1 tron e = NULL;
205 1.1 tron
206 1.1 tron rs->sr_err = LDAP_REFERRAL;
207 1.1 tron rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
208 1.1 tron goto return_results;
209 1.1 tron }
210 1.1 tron
211 1.1 tron if ( pdn.bv_len != 0 ) {
212 1.1 tron /* check parent for "children" acl */
213 1.1 tron rs->sr_err = access_allowed( op, p,
214 1.1 tron children, NULL, ACL_WDEL, NULL );
215 1.1 tron
216 1.1 tron if ( !rs->sr_err ) {
217 1.1 tron Debug( LDAP_DEBUG_TRACE,
218 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": no write "
219 1.1 tron "access to parent\n", 0, 0, 0 );
220 1.1 tron rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
221 1.1 tron rs->sr_text = "no write access to parent";
222 1.1 tron goto return_results;
223 1.1 tron }
224 1.1 tron
225 1.1 tron } else {
226 1.1 tron /* no parent, must be root to delete */
227 1.1 tron if( ! be_isroot( op ) ) {
228 1.1 tron if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
229 1.1 tron || be_shadow_update( op ) ) {
230 1.1 tron p = (Entry *)&slap_entry_root;
231 1.1 tron
232 1.1 tron /* check parent for "children" acl */
233 1.1 tron rs->sr_err = access_allowed( op, p,
234 1.1 tron children, NULL, ACL_WDEL, NULL );
235 1.1 tron
236 1.1 tron p = NULL;
237 1.1 tron
238 1.1 tron if ( !rs->sr_err ) {
239 1.1 tron Debug( LDAP_DEBUG_TRACE,
240 1.1 tron "<=- " LDAP_XSTRING(mdb_delete)
241 1.1 tron ": no access to parent\n",
242 1.1 tron 0, 0, 0 );
243 1.1 tron rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
244 1.1 tron rs->sr_text = "no write access to parent";
245 1.1 tron goto return_results;
246 1.1 tron }
247 1.1 tron
248 1.1 tron } else {
249 1.1 tron Debug( LDAP_DEBUG_TRACE,
250 1.1 tron "<=- " LDAP_XSTRING(mdb_delete)
251 1.1 tron ": no parent and not root\n", 0, 0, 0 );
252 1.1 tron rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
253 1.1 tron goto return_results;
254 1.1 tron }
255 1.1 tron }
256 1.1 tron }
257 1.1 tron
258 1.1 tron if ( get_assert( op ) &&
259 1.1 tron ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
260 1.1 tron {
261 1.1 tron rs->sr_err = LDAP_ASSERTION_FAILED;
262 1.1 tron goto return_results;
263 1.1 tron }
264 1.1 tron
265 1.1 tron rs->sr_err = access_allowed( op, e,
266 1.1 tron entry, NULL, ACL_WDEL, NULL );
267 1.1 tron
268 1.1 tron if ( !rs->sr_err ) {
269 1.1 tron Debug( LDAP_DEBUG_TRACE,
270 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": no write access "
271 1.1 tron "to entry\n", 0, 0, 0 );
272 1.1 tron rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
273 1.1 tron rs->sr_text = "no write access to entry";
274 1.1 tron goto return_results;
275 1.1 tron }
276 1.1 tron
277 1.1 tron if ( !manageDSAit && is_entry_referral( e ) ) {
278 1.1 tron /* entry is a referral, don't allow delete */
279 1.1 tron rs->sr_ref = get_entry_referrals( op, e );
280 1.1 tron
281 1.1 tron Debug( LDAP_DEBUG_TRACE,
282 1.1 tron LDAP_XSTRING(mdb_delete) ": entry is referral\n",
283 1.1 tron 0, 0, 0 );
284 1.1 tron
285 1.1 tron rs->sr_err = LDAP_REFERRAL;
286 1.1 tron rs->sr_matched = ch_strdup( e->e_name.bv_val );
287 1.1 tron rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
288 1.1 tron goto return_results;
289 1.1 tron }
290 1.1 tron
291 1.1 tron /* pre-read */
292 1.1 tron if( op->o_preread ) {
293 1.1 tron if( preread_ctrl == NULL ) {
294 1.1 tron preread_ctrl = &ctrls[num_ctrls++];
295 1.1 tron ctrls[num_ctrls] = NULL;
296 1.1 tron }
297 1.1 tron if( slap_read_controls( op, rs, e,
298 1.1 tron &slap_pre_read_bv, preread_ctrl ) )
299 1.1 tron {
300 1.1 tron Debug( LDAP_DEBUG_TRACE,
301 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": pre-read "
302 1.1 tron "failed!\n", 0, 0, 0 );
303 1.1 tron if ( op->o_preread & SLAP_CONTROL_CRITICAL ) {
304 1.1 tron /* FIXME: is it correct to abort
305 1.1 tron * operation if control fails? */
306 1.1 tron goto return_results;
307 1.1 tron }
308 1.1 tron }
309 1.1 tron }
310 1.1 tron
311 1.1 tron rs->sr_text = NULL;
312 1.1 tron
313 1.1 tron /* Can't do it if we have kids */
314 1.1 tron rs->sr_err = mdb_dn2id_children( op, txn, e );
315 1.1 tron if( rs->sr_err != MDB_NOTFOUND ) {
316 1.1 tron switch( rs->sr_err ) {
317 1.1 tron case 0:
318 1.1 tron Debug(LDAP_DEBUG_ARGS,
319 1.1 tron "<=- " LDAP_XSTRING(mdb_delete)
320 1.1 tron ": non-leaf %s\n",
321 1.1 tron op->o_req_dn.bv_val, 0, 0);
322 1.1 tron rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
323 1.1 tron rs->sr_text = "subordinate objects must be deleted first";
324 1.1 tron break;
325 1.1 tron default:
326 1.1 tron Debug(LDAP_DEBUG_ARGS,
327 1.1 tron "<=- " LDAP_XSTRING(mdb_delete)
328 1.1 tron ": has_children failed: %s (%d)\n",
329 1.1 tron mdb_strerror(rs->sr_err), rs->sr_err, 0 );
330 1.1 tron rs->sr_err = LDAP_OTHER;
331 1.1 tron rs->sr_text = "internal error";
332 1.1 tron }
333 1.1 tron goto return_results;
334 1.1 tron }
335 1.1 tron
336 1.1 tron /* delete from dn2id */
337 1.1 tron rs->sr_err = mdb_dn2id_delete( op, mc, e->e_id, 1 );
338 1.1 tron mdb_cursor_close( mc );
339 1.1 tron if ( rs->sr_err != 0 ) {
340 1.1 tron Debug(LDAP_DEBUG_TRACE,
341 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": dn2id failed: "
342 1.1 tron "%s (%d)\n", mdb_strerror(rs->sr_err), rs->sr_err, 0 );
343 1.1 tron rs->sr_text = "DN index delete failed";
344 1.1 tron rs->sr_err = LDAP_OTHER;
345 1.1 tron goto return_results;
346 1.1 tron }
347 1.1 tron
348 1.1 tron /* delete indices for old attributes */
349 1.1 tron rs->sr_err = mdb_index_entry_del( op, txn, e );
350 1.1 tron if ( rs->sr_err != LDAP_SUCCESS ) {
351 1.1 tron Debug(LDAP_DEBUG_TRACE,
352 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": index failed: "
353 1.1 tron "%s (%d)\n", mdb_strerror(rs->sr_err), rs->sr_err, 0 );
354 1.1 tron rs->sr_text = "entry index delete failed";
355 1.1 tron rs->sr_err = LDAP_OTHER;
356 1.1 tron goto return_results;
357 1.1 tron }
358 1.1 tron
359 1.1 tron /* fixup delete CSN */
360 1.1 tron if ( !SLAP_SHADOW( op->o_bd )) {
361 1.1 tron struct berval vals[2];
362 1.1 tron
363 1.1 tron assert( !BER_BVISNULL( &op->o_csn ) );
364 1.1 tron vals[0] = op->o_csn;
365 1.1 tron BER_BVZERO( &vals[1] );
366 1.1 tron rs->sr_err = mdb_index_values( op, txn, slap_schema.si_ad_entryCSN,
367 1.1 tron vals, 0, SLAP_INDEX_ADD_OP );
368 1.1 tron if ( rs->sr_err != LDAP_SUCCESS ) {
369 1.1 tron rs->sr_text = "entryCSN index update failed";
370 1.1 tron rs->sr_err = LDAP_OTHER;
371 1.1 tron goto return_results;
372 1.1 tron }
373 1.1 tron }
374 1.1 tron
375 1.1 tron /* delete from id2entry */
376 1.1 tron rs->sr_err = mdb_id2entry_delete( op->o_bd, txn, e );
377 1.1 tron if ( rs->sr_err != 0 ) {
378 1.1 tron Debug( LDAP_DEBUG_TRACE,
379 1.1 tron "<=- " LDAP_XSTRING(mdb_delete) ": id2entry failed: "
380 1.1 tron "%s (%d)\n", mdb_strerror(rs->sr_err), rs->sr_err, 0 );
381 1.1 tron rs->sr_text = "entry delete failed";
382 1.1 tron rs->sr_err = LDAP_OTHER;
383 1.1 tron goto return_results;
384 1.1 tron }
385 1.1 tron
386 1.1 tron if ( pdn.bv_len != 0 ) {
387 1.1 tron parent_is_glue = is_entry_glue(p);
388 1.1 tron rs->sr_err = mdb_dn2id_children( op, txn, p );
389 1.1 tron if ( rs->sr_err != MDB_NOTFOUND ) {
390 1.1 tron switch( rs->sr_err ) {
391 1.1 tron case 0:
392 1.1 tron break;
393 1.1 tron default:
394 1.1 tron Debug(LDAP_DEBUG_ARGS,
395 1.1 tron "<=- " LDAP_XSTRING(mdb_delete)
396 1.1 tron ": has_children failed: %s (%d)\n",
397 1.1 tron mdb_strerror(rs->sr_err), rs->sr_err, 0 );
398 1.1 tron rs->sr_err = LDAP_OTHER;
399 1.1 tron rs->sr_text = "internal error";
400 1.1 tron goto return_results;
401 1.1 tron }
402 1.1 tron parent_is_leaf = 1;
403 1.1 tron }
404 1.1 tron mdb_entry_return( op, p );
405 1.1 tron p = NULL;
406 1.1 tron }
407 1.1 tron
408 1.1 tron if( moi == &opinfo ) {
409 1.1 tron LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next );
410 1.1 tron opinfo.moi_oe.oe_key = NULL;
411 1.1 tron if( op->o_noop ) {
412 1.1 tron mdb_txn_abort( txn );
413 1.1 tron rs->sr_err = LDAP_X_NO_OPERATION;
414 1.1 tron txn = NULL;
415 1.1 tron goto return_results;
416 1.1 tron } else {
417 1.1 tron rs->sr_err = mdb_txn_commit( txn );
418 1.1 tron }
419 1.1 tron txn = NULL;
420 1.1 tron }
421 1.1 tron
422 1.1 tron if( rs->sr_err != 0 ) {
423 1.1 tron Debug( LDAP_DEBUG_ANY,
424 1.1 tron LDAP_XSTRING(mdb_delete) ": txn_%s failed: %s (%d)\n",
425 1.1 tron op->o_noop ? "abort (no-op)" : "commit",
426 1.1 tron mdb_strerror(rs->sr_err), rs->sr_err );
427 1.1 tron rs->sr_err = LDAP_OTHER;
428 1.1 tron rs->sr_text = "commit failed";
429 1.1 tron
430 1.1 tron goto return_results;
431 1.1 tron }
432 1.1 tron
433 1.1 tron Debug( LDAP_DEBUG_TRACE,
434 1.1 tron LDAP_XSTRING(mdb_delete) ": deleted%s id=%08lx dn=\"%s\"\n",
435 1.1 tron op->o_noop ? " (no-op)" : "",
436 1.1 tron e->e_id, op->o_req_dn.bv_val );
437 1.1 tron rs->sr_err = LDAP_SUCCESS;
438 1.1 tron rs->sr_text = NULL;
439 1.1 tron if( num_ctrls ) rs->sr_ctrls = ctrls;
440 1.1 tron
441 1.1 tron return_results:
442 1.1 tron if ( rs->sr_err == LDAP_SUCCESS && parent_is_glue && parent_is_leaf ) {
443 1.1 tron op->o_delete_glue_parent = 1;
444 1.1 tron }
445 1.1 tron
446 1.1 tron if ( p != NULL ) {
447 1.1 tron mdb_entry_return( op, p );
448 1.1 tron }
449 1.1 tron
450 1.1 tron /* free entry */
451 1.1 tron if( e != NULL ) {
452 1.1 tron mdb_entry_return( op, e );
453 1.1 tron }
454 1.1 tron
455 1.1 tron if( moi == &opinfo ) {
456 1.1 tron if( txn != NULL ) {
457 1.1 tron mdb_txn_abort( txn );
458 1.1 tron }
459 1.1 tron if ( opinfo.moi_oe.oe_key ) {
460 1.1 tron LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next );
461 1.1 tron }
462 1.1 tron } else {
463 1.1 tron moi->moi_ref--;
464 1.1 tron }
465 1.1 tron
466 1.1 tron send_ldap_result( op, rs );
467 1.1 tron slap_graduate_commit_csn( op );
468 1.1 tron
469 1.1 tron if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
470 1.1 tron slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
471 1.1 tron slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
472 1.1 tron }
473 1.1 tron
474 1.1 tron #if 0
475 1.1 tron if( rs->sr_err == LDAP_SUCCESS && mdb->bi_txn_cp_kbyte ) {
476 1.1 tron TXN_CHECKPOINT( mdb->bi_dbenv,
477 1.1 tron mdb->bi_txn_cp_kbyte, mdb->bi_txn_cp_min, 0 );
478 1.1 tron }
479 1.1 tron #endif
480 1.1 tron return rs->sr_err;
481 1.1 tron }
482