213
214
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
214
215
/* Don't release SERIAL LOCK */
215
216
dblayer_txn_abort_ext(li, &txn, PR_FALSE);
216
218
slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
218
220
if (addingentry_in_cache) {
219
221
/* addingentry is in cache. Remove it once. */
220
CACHE_REMOVE(&inst->inst_cache, addingentry);
222
retval = CACHE_REMOVE(&inst->inst_cache, addingentry);
224
LDAPDebug1Arg(LDAP_DEBUG_CACHE, "ldbm_add: cache_remove %s failed.\n",
225
slapi_entry_get_dn_const(addingentry->ep_entry));
221
227
CACHE_RETURN(&inst->inst_cache, &addingentry);
223
229
backentry_free(&addingentry);
231
237
if (addingentry_in_cache) {
232
238
/* Adding the resetted addingentry to the cache. */
233
if (cache_add_tentative(&inst->inst_cache,
234
addingentry, NULL) != 0) {
235
LDAPDebug0Args(LDAP_DEBUG_CACHE,
236
"cache_add_tentative concurrency detected\n");
239
if (cache_add_tentative(&inst->inst_cache, addingentry, NULL) != 0) {
240
LDAPDebug1Arg(LDAP_DEBUG_CACHE, "cache_add_tentative concurrency detected: %s\n",
241
slapi_entry_get_dn_const(addingentry->ep_entry));
237
242
ldap_result_code = LDAP_ALREADY_EXISTS;
243
addingentry_in_cache = 0;
238
244
goto error_return;
316
* If the parent is conflict, slapi_sdn_get_backend_parent does not support it.
317
* That is, adding children to a conflict entry is not allowed.
308
319
slapi_sdn_get_backend_parent(sdn, &parentsdn, pb->pb_backend);
309
320
/* Check if an entry with the intended DN already exists. */
310
321
done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_DN_ENTRY); /* Could be through this multiple times */
313
324
addr.uniqueid = NULL;
314
325
ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_EXISTING_DN_ENTRY, !is_replicated_operation);
315
if(ldap_result_code==LDAP_OPERATIONS_ERROR ||
316
ldap_result_code==LDAP_INVALID_DN_SYNTAX)
326
if(ldap_result_code==LDAP_OPERATIONS_ERROR || ldap_result_code==LDAP_INVALID_DN_SYNTAX) {
318
327
goto error_return;
321
330
/* if we can find the parent by dn or uniqueid, and the operation has requested the parent
323
if(have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid) &&
324
slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY))
332
if (have_parent_address(&parentsdn, operation->o_params.p.p_add.parentuniqueid) &&
333
slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY)) {
326
334
done_with_pblock_entry(pb,SLAPI_ADD_PARENT_ENTRY); /* Could be through this multiple times */
327
335
addr.sdn = &parentsdn;
329
337
addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
330
ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_PARENT_ENTRY, !is_replicated_operation);
331
/* need to set parentsdn or parentuniqueid if either is not set? */
338
ldap_result_code = get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_PARENT_ENTRY, !is_replicated_operation);
334
341
/* Call the Backend Pre Add plugins */
342
ldap_result_code = LDAP_SUCCESS;
335
343
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
336
rc= plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
344
rc = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN);
338
346
int opreturn = 0;
339
347
if (SLAPI_PLUGIN_NOOP == rc) {
401
410
operation->o_params.p.p_add.parentuniqueid =
402
411
slapi_ch_strdup(slapi_entry_get_uniqueid(parententry->ep_entry));
404
if (slapi_sdn_isempty(&parentsdn)) {
413
if (slapi_sdn_isempty(&parentsdn) ||
414
slapi_sdn_compare(&parentsdn, slapi_entry_get_sdn(parententry->ep_entry))) {
405
415
/* Set the parentsdn now */
406
416
slapi_sdn_set_dn_byval(&parentsdn, slapi_entry_get_dn_const(parententry->ep_entry));
419
LDAPDebug(LDAP_DEBUG_BACKLDBM, "find_entry2modify_only returned NULL parententry pdn: %s, uniqueid: %s\n",
420
slapi_sdn_get_dn(&parentsdn), slapi_sdn_get_dn(&parentsdn), addr.uniqueid?addr.uniqueid:"none");
409
422
modify_init(&parent_modify_c,parententry);
412
425
/* Check if the entry we have been asked to add already exists */
414
427
Slapi_Entry *entry;
415
slapi_pblock_get( pb, SLAPI_ADD_EXISTING_DN_ENTRY, &entry);
418
/* The entry already exists */
419
ldap_result_code= LDAP_ALREADY_EXISTS;
428
slapi_pblock_get(pb, SLAPI_ADD_EXISTING_DN_ENTRY, &entry);
430
if (is_resurect_operation) {
431
Slapi_Entry *uniqentry;
432
slapi_pblock_get(pb, SLAPI_ADD_EXISTING_UNIQUEID_ENTRY, &uniqentry);
433
if (uniqentry == entry) {
435
* adding entry having the uniqueid exists.
436
* No need to resurrect.
438
ldap_result_code = LDAP_SUCCESS;
440
/* The entry having the DN already exists */
442
if (PL_strcmp(slapi_entry_get_uniqueid(entry),
443
slapi_entry_get_uniqueid(uniqentry))) {
444
/* Not match; conflict. */
445
ldap_result_code = LDAP_ALREADY_EXISTS;
447
/* Same entry; no need to resurrect. */
448
ldap_result_code = LDAP_SUCCESS;
451
ldap_result_code = LDAP_ALREADY_EXISTS;
455
/* The entry already exists */
456
ldap_result_code = LDAP_ALREADY_EXISTS;
420
458
goto error_return;
437
475
slapi_sdn_done(&ancestorsdn);
438
476
if ( ancestorentry != NULL )
441
check_entry_for_referral(pb, ancestorentry->ep_entry,
442
backentry_get_ndn(ancestorentry), "ldbm_back_add");
478
int sentreferral= check_entry_for_referral(pb, ancestorentry->ep_entry, backentry_get_ndn(ancestorentry), "ldbm_back_add");
443
479
CACHE_RETURN( &inst->inst_cache, &ancestorentry );
454
490
/* no need to check the schema as this is a replication add */
455
if(!is_replicated_operation){
491
if (!is_replicated_operation) {
456
492
if ((operation_is_flag_set(operation,OP_FLAG_ACTION_SCHEMA_CHECK))
457
493
&& (slapi_entry_schema_check(pb, e) != 0))
459
LDAPDebug(LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0, 0);
460
ldap_result_code = LDAP_OBJECT_CLASS_VIOLATION;
461
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
495
LDAPDebug(LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0, 0);
496
ldap_result_code = LDAP_OBJECT_CLASS_VIOLATION;
497
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
465
/* Check attribute syntax */
466
if (slapi_entry_syntax_check(pb, e, 0) != 0)
468
LDAPDebug(LDAP_DEBUG_TRACE, "entry failed syntax check\n", 0, 0, 0);
469
ldap_result_code = LDAP_INVALID_SYNTAX;
470
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
501
/* Check attribute syntax */
502
if (slapi_entry_syntax_check(pb, e, 0) != 0)
504
LDAPDebug(LDAP_DEBUG_TRACE, "entry failed syntax check\n", 0, 0, 0);
505
ldap_result_code = LDAP_INVALID_SYNTAX;
506
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
475
511
opcsn = operation_get_csn (operation);
476
512
if(is_resurect_operation)
507
543
if (NULL == sdn) {
508
544
LDAPDebug0Args(LDAP_DEBUG_ANY, "ldbm_back_add: Null target dn\n");
545
ldap_result_code = LDAP_OPERATIONS_ERROR;
509
546
goto error_return;
511
548
dn = slapi_sdn_get_dn(sdn);
512
549
slapi_entry_set_sdn(addingentry->ep_entry, sdn); /* The DN is passed into the entry. */
550
/* not just e_sdn, e_rsdn needs to be updated. */
551
slapi_rdn_set_all_dn(slapi_entry_get_srdn(addingentry->ep_entry),
552
slapi_entry_get_dn_const(addingentry->ep_entry));
513
553
/* LPREPL: the DN is normalized...Somehow who should get a not normalized one */
514
554
addingentry->ep_id = slapi_entry_attr_get_ulong(addingentry->ep_entry,"entryid");
515
555
slapi_entry_attr_delete(addingentry->ep_entry, SLAPI_ATTR_VALUE_PARENT_UNIQUEID);
673
713
Slapi_DN ancestorsdn;
674
714
struct backentry *ancestorentry;
676
LDAPDebug( LDAP_DEBUG_TRACE,
677
"parent does not exist, pdn = %s\n",
678
slapi_sdn_get_dn(&parentsdn), 0, 0 );
716
LDAPDebug1Arg(LDAP_DEBUG_BACKLDBM, "ldbm_add: Parent \"%s\" does not exist. "
717
"It might be a conflict entry.\n", slapi_sdn_get_dn(&parentsdn));
680
718
slapi_sdn_init(&ancestorsdn);
681
719
ancestorentry = dn2ancestor(be, &parentsdn, &ancestorsdn, &txn, &err );
682
720
CACHE_RETURN( &inst->inst_cache, &ancestorentry );
687
725
slapi_sdn_done(&ancestorsdn);
688
726
goto error_return;
690
ldap_result_code = plugin_call_acl_plugin (pb, e, NULL, NULL, SLAPI_ACL_ADD,
691
ACLPLUGIN_ACCESS_DEFAULT, &errbuf );
728
ldap_result_code = plugin_call_acl_plugin(pb, e, NULL, NULL, SLAPI_ACL_ADD,
729
ACLPLUGIN_ACCESS_DEFAULT, &errbuf);
692
730
if ( ldap_result_code != LDAP_SUCCESS )
694
LDAPDebug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 );
732
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "no access to parent, pdn = %s\n",
733
slapi_sdn_get_dn(&parentsdn));
695
734
ldap_result_message= errbuf;
696
735
goto error_return;
698
737
pid = parententry->ep_id;
739
/* We may need to adjust the DN since parent could be a resrected conflict entry... */
740
if (!slapi_sdn_isparent(slapi_entry_get_sdn_const(parententry->ep_entry),
741
slapi_entry_get_sdn_const(addingentry->ep_entry))) {
742
Slapi_DN adjustedsdn = {0};
743
char *adjusteddn = slapi_ch_smprintf("%s,%s",
744
slapi_entry_get_rdn_const(addingentry->ep_entry),
745
slapi_entry_get_dn_const(parententry->ep_entry));
746
LDAPDebug2Args(LDAP_DEBUG_BACKLDBM, "ldbm_add: adjusting dn: %s --> %s\n",
747
slapi_entry_get_dn(addingentry->ep_entry), adjusteddn);
748
slapi_sdn_set_normdn_passin(&adjustedsdn, adjusteddn);
749
slapi_entry_set_sdn(addingentry->ep_entry, &adjustedsdn);
750
/* not just e_sdn, e_rsdn needs to be updated. */
751
slapi_rdn_set_all_dn(slapi_entry_get_srdn(addingentry->ep_entry), adjusteddn);
752
slapi_sdn_done(&adjustedsdn);
701
756
{ /* no parent */
702
if ( !isroot && !is_replicated_operation)
704
LDAPDebug( LDAP_DEBUG_TRACE, "no parent & not root\n",
757
if (!isroot && !is_replicated_operation) {
758
LDAPDebug0Args(LDAP_DEBUG_TRACE, "no parent & not root\n");
706
759
ldap_result_code= LDAP_INSUFFICIENT_ACCESS;
707
760
goto error_return;
731
784
* operational attributes to ensure that the cache is sized correctly. */
732
785
if ( cache_add_tentative( &inst->inst_cache, addingentry, NULL )!= 0 )
734
LDAPDebug( LDAP_DEBUG_CACHE, "cache_add_tentative concurrency detected\n", 0, 0, 0 );
787
LDAPDebug1Arg(LDAP_DEBUG_CACHE, "cache_add_tentative concurrency detected: %s\n",
788
slapi_entry_get_dn_const(addingentry->ep_entry));
735
789
ldap_result_code= LDAP_ALREADY_EXISTS;
736
790
goto error_return;
738
addingentry_in_cache= 1;
792
addingentry_in_cache = 1;
741
795
* Before we add the entry, find out if the syntax of the aci
743
797
* the entry if the syntax is incorrect.
745
799
if ( plugin_call_acl_verify_syntax (pb, addingentry->ep_entry, &errbuf) != 0 ) {
746
LDAPDebug( LDAP_DEBUG_TRACE, "ACL syntax error\n", 0,0,0);
800
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "ACL syntax error: %s\n",
801
slapi_entry_get_dn_const(addingentry->ep_entry));
747
802
ldap_result_code= LDAP_INVALID_SYNTAX;
748
803
ldap_result_message= errbuf;
749
804
goto error_return;
752
807
/* Having decided that we're really going to do the operation, let's modify
753
808
the in-memory state of the parent to reflect the new child (update
754
809
subordinate count specifically */
755
if (NULL != parententry)
757
811
retval = parent_update_on_childchange(&parent_modify_c,
758
PARENTUPDATE_ADD, NULL);
812
is_resurect_operation?PARENTUPDATE_RESURECT:PARENTUPDATE_ADD,
759
814
/* The modify context now contains info needed later */
816
LDAPDebug2Args(LDAP_DEBUG_BACKLDBM, "parent_update_on_childchange: %s, rc=%d\n",
817
slapi_entry_get_dn_const(addingentry->ep_entry), retval);
761
818
ldap_result_code= LDAP_OPERATIONS_ERROR;
762
819
goto error_return;
780
837
not_an_error = 1;
781
838
rc = retval = LDAP_SUCCESS;
783
LDAPDebug1Arg( LDAP_DEBUG_TRACE, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin "
784
"returned error code %d\n", retval );
840
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin "
841
"returned error code %d\n", retval );
785
842
if (!ldap_result_code) {
786
843
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
788
845
if (!ldap_result_code) {
789
LDAPDebug0Args( LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin "
790
"returned error but did not setSLAPI_RESULT_CODE \n" );
791
846
ldap_result_code = LDAP_OPERATIONS_ERROR;
792
847
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
810
LDAPDebug( LDAP_DEBUG_TRACE, "id2entry_add failed, err=%d %s\n",
811
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
867
LDAPDebug(LDAP_DEBUG_TRACE, "id2entry_add(%s) failed, err=%d %s\n",
868
slapi_entry_get_dn_const(addingentry->ep_entry),
869
retval, (msg = dblayer_strerror( retval )) ? msg : "");
812
870
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
813
871
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
817
875
goto error_return;
819
if(is_resurect_operation)
877
if (is_resurect_operation) {
821
878
retval = index_addordel_string(be,SLAPI_ATTR_OBJECTCLASS,SLAPI_ATTR_VALUE_TOMBSTONE,addingentry->ep_id,BE_INDEX_DEL|BE_INDEX_EQUALITY,&txn);
822
879
if (DB_LOCK_DEADLOCK == retval) {
823
880
LDAPDebug( LDAP_DEBUG_ARGS, "add 2 DB_LOCK_DEADLOCK\n", 0, 0, 0 );
828
LDAPDebug( LDAP_DEBUG_TRACE, "add 1 BAD, err=%d %s\n",
829
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
830
ADD_SET_ERROR(ldap_result_code,
831
LDAP_OPERATIONS_ERROR, retry_count);
885
LDAPDebug(LDAP_DEBUG_TRACE, "index_addordel_string TOMBSTONE (%s), err=%d %s\n",
886
slapi_entry_get_dn_const(addingentry->ep_entry),
887
retval, (msg = dblayer_strerror( retval )) ? msg : "");
888
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
832
889
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
834
891
goto diskfull_return;
844
901
if (0 != retval) {
845
LDAPDebug( LDAP_DEBUG_TRACE, "add 2 BAD, err=%d %s\n",
846
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
847
ADD_SET_ERROR(ldap_result_code,
848
LDAP_OPERATIONS_ERROR, retry_count);
902
LDAPDebug(LDAP_DEBUG_TRACE, "index_addordel_string UNIQUEID (%s), err=%d %s\n",
903
slapi_entry_get_dn_const(addingentry->ep_entry),
904
retval, (msg = dblayer_strerror( retval )) ? msg : "");
905
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
849
906
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
851
908
goto diskfull_return;
865
922
if (0 != retval) {
866
LDAPDebug( LDAP_DEBUG_TRACE, "add 3 BAD, err=%d %s\n",
867
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
868
ADD_SET_ERROR(ldap_result_code,
869
LDAP_OPERATIONS_ERROR, retry_count);
923
LDAPDebug(LDAP_DEBUG_TRACE, "index_addordel_string ENTRYDN (%s), err=%d %s\n",
924
slapi_entry_get_dn_const(addingentry->ep_entry),
925
retval, (msg = dblayer_strerror( retval )) ? msg : "");
926
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
870
927
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
872
929
goto diskfull_return;
874
931
goto error_return;
933
/* Need to delete the entryrdn index of the resurrected tombstone... */
934
if (entryrdn_get_switch()) { /* subtree-rename: on */
935
if (tombstoneentry) {
936
retval = entryrdn_index_entry(be, tombstoneentry, BE_INDEX_DEL, &txn);
938
LDAPDebug(LDAP_DEBUG_ANY, "Resurrecting %s: failed to remove entryrdn index, err=%d %s\n",
939
slapi_entry_get_dn_const(tombstoneentry->ep_entry),
940
retval, (msg = dblayer_strerror( retval )) ? msg : "");
877
946
if (is_tombstone_operation)
879
948
retval = index_addordel_entry( be, addingentry, BE_INDEX_ADD | BE_INDEX_TOMBSTONE, &txn );
892
LDAPDebug2Args(LDAP_DEBUG_ANY,
893
"add: attempt to index %lu failed (rc=%d)\n",
961
LDAPDebug2Args(LDAP_DEBUG_ANY, "add: attempt to index %lu failed; rc=%d\n",
894
962
(u_long)addingentry->ep_id, retval);
895
963
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
896
964
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
912
LDAPDebug( LDAP_DEBUG_TRACE, "add 1 BAD, err=%d %s\n",
913
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
914
ADD_SET_ERROR(ldap_result_code,
915
LDAP_OPERATIONS_ERROR, retry_count);
980
LDAPDebug(LDAP_DEBUG_BACKLDBM, "modify_update_all: %s (%lu) failed; rc=%d\n",
981
slapi_entry_get_dn(addingentry->ep_entry), (u_long)addingentry->ep_id, retval);
982
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
916
983
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
918
985
goto diskfull_return;
928
995
retval= vlv_update_all_indexes(&txn, be, pb, NULL, addingentry);
929
996
if (DB_LOCK_DEADLOCK == retval) {
930
LDAPDebug( LDAP_DEBUG_ARGS,
931
"add DEADLOCK vlv_update_index\n", 0, 0, 0 );
997
LDAPDebug(LDAP_DEBUG_ARGS,
998
"add DEADLOCK vlv_update_index\n", 0, 0, 0 );
936
LDAPDebug( LDAP_DEBUG_TRACE,
937
"vlv_update_index failed, err=%d %s\n",
938
retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 );
939
ADD_SET_ERROR(ldap_result_code,
940
LDAP_OPERATIONS_ERROR, retry_count);
1003
LDAPDebug2Args(LDAP_DEBUG_TRACE,
1004
"vlv_update_index failed, err=%d %s\n",
1005
retval, (msg = dblayer_strerror( retval )) ? msg : "");
1006
ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
941
1007
if (LDBM_OS_ERR_IS_DISKFULL(retval)) {
943
1009
goto diskfull_return;
994
1060
slapi_pblock_set( pb, SLAPI_ENTRY_PRE_OP, NULL );
995
1061
slapi_pblock_set( pb, SLAPI_ENTRY_POST_OP, slapi_entry_dup( addingentry->ep_entry ));
997
if(is_resurect_operation)
1063
if (is_resurect_operation) {
1000
1065
* We can now switch the tombstone entry with the real entry.
1002
if (cache_replace( &inst->inst_cache, tombstoneentry, addingentry ) != 0 )
1067
retval = cache_replace(&inst->inst_cache, tombstoneentry, addingentry);
1004
1069
/* This happens if the dn of addingentry already exists */
1005
cache_unlock_entry( &inst->inst_cache, tombstoneentry );
1006
1070
ADD_SET_ERROR(ldap_result_code, LDAP_ALREADY_EXISTS, retry_count);
1071
LDAPDebug2Args(LDAP_DEBUG_CACHE, "ldap_add: cache_replace concurrency detected: %s (rc: %d)\n",
1072
slapi_entry_get_dn_const(addingentry->ep_entry), retval);
1007
1074
goto error_return;
1076
if (addingentry_in_cache) { /* decrease the refcnt added by tentative */
1077
CACHE_RETURN( &inst->inst_cache, &addingentry );
1079
addingentry_in_cache = 1; /* reset it to make it sure... */
1010
1081
* The tombstone was locked down in the cache... we can
1011
1082
* get rid of the entry in the cache now.
1083
* We cannot expect tombstoneentry exists from now on.
1013
cache_unlock_entry( &inst->inst_cache, tombstoneentry );
1014
CACHE_RETURN( &inst->inst_cache, &tombstoneentry );
1015
tombstone_in_cache = 0; /* deleted */
1085
if (entryrdn_get_switch()) { /* subtree-rename: on */
1086
/* since the op was successful, delete the tombstone dn from the dn cache */
1087
struct backdn *bdn = dncache_find_id(&inst->inst_dncache,
1088
tombstoneentry->ep_id);
1089
if (bdn) { /* in the dncache, remove it. */
1090
CACHE_REMOVE(&inst->inst_dncache, bdn);
1091
CACHE_RETURN(&inst->inst_dncache, &bdn);
1094
cache_unlock_entry(&inst->inst_cache, tombstoneentry);
1095
CACHE_RETURN(&inst->inst_cache, &tombstoneentry);
1096
tombstone_in_cache = 0;
1017
1098
if (parent_found)
1019
1100
/* switch the parent entry copy into play */
1020
modify_switch_entries( &parent_modify_c,be);
1101
modify_switch_entries(&parent_modify_c,be);
1102
parent_switched = 1;
1023
1105
if (ruv_c_init) {
1024
1106
if (modify_switch_entries(&ruv_c, be) != 0 ) {
1025
1107
ldap_result_code= LDAP_OPERATIONS_ERROR;
1026
LDAPDebug( LDAP_DEBUG_ANY,
1027
"ldbm_back_add: modify_switch_entries failed\n", 0, 0, 0);
1108
LDAPDebug0Args(LDAP_DEBUG_ANY,
1109
"ldbm_back_add: modify_switch_entries failed\n");
1028
1110
goto error_return;
1038
1120
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
1040
1122
if (!ldap_result_code) {
1041
LDAPDebug0Args( LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_POST_ADD_FN plugin "
1042
"returned error but did not set SLAPI_RESULT_CODE\n" );
1043
1123
ldap_result_code = LDAP_OPERATIONS_ERROR;
1044
1124
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code);
1074
1155
next_id_return( be, addingentry->ep_id );
1076
if ( NULL != addingentry )
1078
1159
if ( addingentry_in_cache )
1081
1162
CACHE_REMOVE(&inst->inst_cache, addingentry);
1083
addingentry_in_cache = 0;
1085
backentry_clear_entry(addingentry); /* e is released in the frontend */
1086
backentry_free( &addingentry ); /* release the backend wrapper, here */
1088
if(tombstone_in_cache && inst)
1090
CACHE_RETURN(&inst->inst_cache, &tombstoneentry);
1163
/* tell frontend not to free this entry */
1164
slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
1169
if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
1170
backentry_clear_entry(addingentry); /* e is released in the frontend */
1172
backentry_free( &addingentry ); /* release the backend wrapper, here */
1093
1175
if (rc == DB_RUNRECOVERY) {
1094
1176
dblayer_remember_disk_filled(li);
1095
1177
ldbm_nasty("Add",80,rc);
1097
1179
} else if (0 == rc) {
1098
1180
rc = SLAPI_FAIL_GENERAL;
1182
if (parent_switched){
1184
* Restore the old parent entry, switch the new with the original.
1185
* Otherwise the numsubordinate count will be off, and could later
1186
* be written to disk.
1188
modify_unswitch_entries( &parent_modify_c,be);
1100
1190
diskfull_return:
1101
1191
if (disk_full) {
1102
rc= return_on_disk_full(li);
1192
rc = return_on_disk_full(li);
1104
1194
/* It is safer not to abort when the transaction is not started. */
1105
1195
if (txn.back_txn_txn && (txn.back_txn_txn != parent_txn)) {
1131
1221
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &opreturn);
1223
if (addingentry_in_cache && addingentry && inst) {
1224
CACHE_REMOVE(&inst->inst_cache, addingentry);
1225
/* tell frontend not to free this entry */
1226
slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
1229
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
1135
1232
/* Release SERIAL LOCK */
1136
dblayer_txn_abort(be, &txn); /* abort crashes in case disk full */
1234
dblayer_txn_abort(be, &txn); /* abort crashes in case disk full */
1137
1236
/* txn is no longer valid - reset the txn pointer to the parent */
1138
1237
slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
1246
if(tombstone_in_cache && tombstoneentry) {
1247
cache_unlock_entry(&inst->inst_cache, tombstoneentry);
1248
CACHE_RETURN(&inst->inst_cache, &tombstoneentry);
1147
1250
if (addingentry_in_cache && addingentry) {
1148
if (entryrdn_get_switch()) { /* subtree-rename: on */
1251
if ((0 == retval) && entryrdn_get_switch()) { /* subtree-rename: on */
1149
1252
/* since adding the entry to the entry cache was successful,
1150
1253
* let's add the dn to dncache, if not yet done. */
1151
1254
struct backdn *bdn = dncache_find_id(&inst->inst_dncache,