116
116
ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
118
118
if (mc->old_entry!=NULL && mc->new_entry!=NULL) {
119
ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
120
if (ret == 0) mc->new_entry_in_cache = 1;
119
ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
121
mc->new_entry_in_cache = 1;
123
LDAPDebug(LDAP_DEBUG_CACHE, "modify_switch_entries: replacing %s with %s failed (%d)\n",
124
slapi_entry_get_dn(mc->old_entry->ep_entry),
125
slapi_entry_get_dn(mc->new_entry->ep_entry), ret);
132
* Switch the new with the old(original) - undoing modify_switch_entries()
133
* This expects modify_term() to be called next, as the old "new" entry
134
* is now gone(replaced by the original entry).
137
modify_unswitch_entries(modify_context *mc,backend *be)
139
struct backentry *tmp_be;
140
ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
143
if (mc->old_entry!=NULL && mc->new_entry!=NULL) {
144
/* switch the entries, and reset the new, new, entry */
145
tmp_be = mc->new_entry;
146
mc->new_entry = mc->old_entry;
147
mc->new_entry->ep_state = 0;
148
mc->new_entry->ep_refcnt = 0;
149
mc->new_entry_in_cache = 0;
150
mc->old_entry = tmp_be;
152
ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
155
* The new entry was originally locked, so since we did the
156
* switch we need to unlock the "new" entry, and return the
157
* "old" one. modify_term() will then return the "new" entry.
159
cache_unlock_entry(&inst->inst_cache, mc->new_entry);
160
CACHE_RETURN( &(inst->inst_cache), &(mc->old_entry) );
161
mc->new_entry_in_cache = 1;
162
mc->old_entry = NULL;
164
LDAPDebug(LDAP_DEBUG_CACHE, "modify_unswitch_entries: replacing %s with %s failed (%d)\n",
165
slapi_entry_get_dn(mc->old_entry->ep_entry),
166
slapi_entry_get_dn(mc->new_entry->ep_entry), ret);
253
301
* If the objectClass attribute type was modified in any way, expand
254
302
* the objectClass values to reflect the inheritance hierarchy.
256
for ( i = 0; mods[i] != NULL && !repl_op; ++i ) {
304
for ( i = 0; (mods != NULL) && (mods[i] != NULL) && !repl_op; ++i ) {
257
305
if ( 0 == strcasecmp( SLAPI_ATTR_OBJECTCLASS, mods[i]->mod_type )) {
258
306
slapi_schema_expand_objectclasses( ec->ep_entry );
521
569
if ( !is_fixup_operation )
523
if (slapi_entry_flag_is_set(e->ep_entry, SLAPI_ENTRY_FLAG_TOMBSTONE) ) {
571
if (!repl_op && slapi_entry_flag_is_set(e->ep_entry, SLAPI_ENTRY_FLAG_TOMBSTONE) ) {
524
572
ldap_result_code = LDAP_UNWILLING_TO_PERFORM;
525
573
ldap_result_message = "Operation not allowed on tombstone entry.";
526
574
slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_modify",
757
805
MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count);
758
806
goto error_return;
809
/* we must return both e (which has been deleted) and new entry ec */
810
/* cache_replace removes e from the caches */
811
cache_unlock_entry( &inst->inst_cache, e );
812
CACHE_RETURN( &inst->inst_cache, &e );
760
814
/* lock new entry in cache to prevent usage until we are complete */
761
815
cache_lock_entry( &inst->inst_cache, ec );
767
821
/* invalidate virtual cache */
768
822
ec->ep_entry->e_virtual_watermark = 0;
770
/* we must return both e (which has been deleted) and new entry ec */
771
/* cache_replace removes e from the caches */
772
cache_unlock_entry( &inst->inst_cache, e );
773
CACHE_RETURN( &inst->inst_cache, &e );
775
825
* LP Fix of crash when the commit will fail:
776
826
* If the commit fail, the common error path will
851
901
LDAPDebug1Arg( LDAP_DEBUG_TRACE, "SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN plugin "
852
902
"returned error code %d\n", retval );
853
903
slapi_pblock_get(pb, SLAPI_RESULT_CODE, &ldap_result_code);
904
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
854
905
slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &opreturn);
856
907
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ? &ldap_result_code : &retval);
873
924
CACHE_REMOVE( &inst->inst_cache, ec );
874
925
/* if ec was in cache, e was not - add back e */
876
CACHE_ADD( &inst->inst_cache, e, NULL );
877
cache_lock_entry( &inst->inst_cache, e );
927
if (CACHE_ADD( &inst->inst_cache, e, NULL )) {
928
LDAPDebug1Arg(LDAP_DEBUG_CACHE, "ldbm_modify: CACHE_ADD %s failed\n",
929
slapi_entry_get_dn(e->ep_entry));
882
935
slapi_mods_done(&smods);
884
if (inst && ec_in_cache)
886
cache_unlock_entry( &inst->inst_cache, ec);
887
CACHE_RETURN( &inst->inst_cache, &ec );
896
cache_unlock_entry( &inst->inst_cache, e);
897
CACHE_RETURN( &inst->inst_cache, &e);
939
cache_unlock_entry( &inst->inst_cache, ec);
940
CACHE_RETURN( &inst->inst_cache, &ec );
943
/* if ec was not in cache, cache_replace was not done.
944
* i.e., e was not unlocked. */
946
cache_unlock_entry( &inst->inst_cache, e);
947
CACHE_RETURN( &inst->inst_cache, &e);
899
950
if (inst->inst_ref_count) {
900
951
slapi_counter_decrement(inst->inst_ref_count);
940
991
/* remove any attempts by the user to modify these attrs */
941
for ( i = 0; mods[i] != NULL; i++ ) {
992
for ( i = 0; (mods != NULL) && (mods[i] != NULL); i++ ) {
942
993
if ( strcasecmp( mods[i]->mod_type, numsubordinates ) == 0
943
994
|| strcasecmp( mods[i]->mod_type, hassubordinates ) == 0 )