Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit b5cd24778cae8c8730c432f3b2a190680100c2bc
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Apr 21 11:32:55 2014 -0400
Ticket 47771 - Cherry pick issue parentsdn freed twice
Called slapi_sdn_done twice for the same local variable.
https://fedorahosted.org/389/ticket/47771
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index c80d75a..f6e6005 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -361,6 +361,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
retval = -1;
CACHE_RETURN(&(inst->inst_cache), &parent);
+ slapi_sdn_done(&parentsdn);
goto error_return;
} else {
/* entry locked, move on */
@@ -397,6 +398,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
op, &haschildren);
/* The modify context now contains info needed later */
if (0 != retval) {
+ slapi_sdn_done(&parentsdn);
ldap_result_code= LDAP_OPERATIONS_ERROR;
goto error_return;
}
@@ -1247,7 +1249,6 @@ diskfull_return:
slapi_ch_free((void**)&errbuf);
slapi_sdn_done(&nscpEntrySDN);
slapi_ch_free_string(&e_uniqueid);
- slapi_sdn_done(&parentsdn);
if (pb->pb_conn)
{
slapi_log_error (SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%" NSPRIu64 " op=%d\n", pb->pb_conn->c_connid, operation->o_opid);
9 years, 5 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entry.c | 2 +-
ldap/servers/slapd/valueset.c | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
New commits:
commit 5e45f459bbad53e63b8ff8308a934559840e23df
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Apr 16 15:04:36 2014 -0700
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values
Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used. It sometimes different from the attribute syntax
based sorting and failed to find out an attribute. This patch passes
an attribute syntax info for sorting.
Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.
https://fedorahosted.org/389/ticket/346
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52)
(cherry picked from commit 821297df835b7d5235d66b592613c89d991d4049)
(cherry picked from commit e97f2b8f2a42d4ceca4020614fd7388e4e319bab)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 5950492..20ac8ea 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2602,7 +2602,7 @@ slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *valu
Slapi_Attr **a= NULL;
attrlist_find_or_create(&e->e_attrs, type, &a);
if(value != (Slapi_Value *) NULL) {
- slapi_valueset_add_value ( &(*a)->a_present_values, value);
+ slapi_valueset_add_attr_value_ext(*a, &(*a)->a_present_values, (Slapi_Value *)value, 0);
}
return 0;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index e83e740..960ad79 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -895,16 +895,10 @@ valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Sla
"slapi_attr_values2keys_sv failed for type %s\n",
a->a_type, 0, 0 );
} else {
- struct berval *bv1, *bv2;
+ const struct berval *bv1, *bv2;
bv1 = &keyvals[0]->bv;
bv2 = &keyvals[1]->bv;
- if ( bv1->bv_len < bv2->bv_len ) {
- rc = -1;
- } else if ( bv1->bv_len > bv2->bv_len ) {
- rc = 1;
- } else {
- rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
- }
+ rc = slapi_berval_cmp (bv1, bv2);
}
if (keyvals != NULL)
valuearray_free( &keyvals );
9 years, 5 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entry.c | 2 +-
ldap/servers/slapd/valueset.c | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
New commits:
commit e97f2b8f2a42d4ceca4020614fd7388e4e319bab
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Apr 16 15:04:36 2014 -0700
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values
Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used. It sometimes different from the attribute syntax
based sorting and failed to find out an attribute. This patch passes
an attribute syntax info for sorting.
Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.
https://fedorahosted.org/389/ticket/346
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52)
(cherry picked from commit 821297df835b7d5235d66b592613c89d991d4049)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 616d471..f65bea7 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2651,7 +2651,7 @@ slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *valu
Slapi_Attr **a= NULL;
attrlist_find_or_create(&e->e_attrs, type, &a);
if(value != (Slapi_Value *) NULL) {
- slapi_valueset_add_value ( &(*a)->a_present_values, value);
+ slapi_valueset_add_attr_value_ext(*a, &(*a)->a_present_values, (Slapi_Value *)value, 0);
}
return 0;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index a3ac7b7..9945d60 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -937,16 +937,10 @@ valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Sla
*/
rc = strcasecmp(v1->bv.bv_val, v2->bv.bv_val);
} else {
- struct berval *bv1, *bv2;
+ const struct berval *bv1, *bv2;
bv1 = &keyvals[0]->bv;
bv2 = &keyvals[1]->bv;
- if ( bv1->bv_len < bv2->bv_len ) {
- rc = -1;
- } else if ( bv1->bv_len > bv2->bv_len ) {
- rc = 1;
- } else {
- rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
- }
+ rc = slapi_berval_cmp (bv1, bv2);
}
if (keyvals != NULL)
valuearray_free( &keyvals );
9 years, 5 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entry.c | 2 +-
ldap/servers/slapd/valueset.c | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
New commits:
commit 821297df835b7d5235d66b592613c89d991d4049
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Apr 16 15:04:36 2014 -0700
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values
Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used. It sometimes different from the attribute syntax
based sorting and failed to find out an attribute. This patch passes
an attribute syntax info for sorting.
Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.
https://fedorahosted.org/389/ticket/346
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 30228c3..12a9317 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2800,7 +2800,7 @@ slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *valu
Slapi_Attr **a= NULL;
attrlist_find_or_create(&e->e_attrs, type, &a);
if(value != (Slapi_Value *) NULL) {
- slapi_valueset_add_value ( &(*a)->a_present_values, value);
+ slapi_valueset_add_attr_value_ext(*a, &(*a)->a_present_values, (Slapi_Value *)value, 0);
}
return 0;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 0740c38..1378bd1 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -926,16 +926,10 @@ valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Sla
"slapi_attr_values2keys_sv failed for type %s\n",
a->a_type, 0, 0 );
} else {
- struct berval *bv1, *bv2;
+ const struct berval *bv1, *bv2;
bv1 = &keyvals[0]->bv;
bv2 = &keyvals[1]->bv;
- if ( bv1->bv_len < bv2->bv_len ) {
- rc = -1;
- } else if ( bv1->bv_len > bv2->bv_len ) {
- rc = 1;
- } else {
- rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
- }
+ rc = slapi_berval_cmp (bv1, bv2);
}
if (keyvals != NULL)
valuearray_free( &keyvals );
9 years, 5 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entry.c | 2 +-
ldap/servers/slapd/valueset.c | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
New commits:
commit 136fa64f95263ffcaca5e855b771b5d377e3de52
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Apr 16 15:04:36 2014 -0700
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values
Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used. It sometimes different from the attribute syntax
based sorting and failed to find out an attribute. This patch passes
an attribute syntax info for sorting.
Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.
https://fedorahosted.org/389/ticket/346
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 72ece66..adf7860 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2818,7 +2818,7 @@ slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *valu
Slapi_Attr **a= NULL;
attrlist_find_or_create(&e->e_attrs, type, &a);
if(value != (Slapi_Value *) NULL) {
- slapi_valueset_add_value ( &(*a)->a_present_values, value);
+ slapi_valueset_add_attr_value_ext(*a, &(*a)->a_present_values, (Slapi_Value *)value, 0);
}
return 0;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 0740c38..1378bd1 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -926,16 +926,10 @@ valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Sla
"slapi_attr_values2keys_sv failed for type %s\n",
a->a_type, 0, 0 );
} else {
- struct berval *bv1, *bv2;
+ const struct berval *bv1, *bv2;
bv1 = &keyvals[0]->bv;
bv2 = &keyvals[1]->bv;
- if ( bv1->bv_len < bv2->bv_len ) {
- rc = -1;
- } else if ( bv1->bv_len > bv2->bv_len ) {
- rc = 1;
- } else {
- rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
- }
+ rc = slapi_berval_cmp (bv1, bv2);
}
if (keyvals != NULL)
valuearray_free( &keyvals );
9 years, 5 months
ldap/servers
by Ludwig Krispenz
ldap/servers/slapd/result.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit fb71aa9a57ff619dcf0631532713cdd0e4928c17
Author: Ludwig Krispenz <lkrispen(a)redhat.com>
Date: Thu Apr 17 14:06:51 2014 +0200
fix jenkins warning
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 7b45e75..fa1788c 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1157,7 +1157,7 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_
char *current_type_name = NULL;
int rewrite_rfc1274 = 0;
int vattr_flags = 0;
- char *dn = NULL;
+ const char *dn = NULL;
char **default_attrs = NULL;
if(real_attrs_only == SLAPI_SEND_VATTR_FLAG_REALONLY)
9 years, 5 months
ldap/schema ldap/servers
by Ludwig Krispenz
ldap/schema/01core389.ldif | 1 +
ldap/servers/slapd/result.c | 17 +++++++++++++++++
ldap/servers/slapd/slap.h | 1 +
3 files changed, 19 insertions(+)
New commits:
commit c6167e7b68e3983ff0922cbcba3e3ee2fe405174
Author: Ludwig Krispenz <lkrispen(a)redhat.com>
Date: Wed Apr 16 14:35:36 2014 +0200
Ticket 47761 - Return all attributes in rootdse without explicit request
Bug Description: a search for the rootdse: -s base -b ""
only returns the user attributes not the
operational attributes like "supportedControl"
This is correct inLDAPv3, and behaviour was introduced
with fix for #47634, but for backward compatibility
the old behaviour should be configurable
Fix Description: Introduce a multivalued attribute to specify the
attribites which should be returned without
specific request
https://fedorahosted.org/389/ticket/47634
Reviewed by: richm, thanks
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
index c5e4877..6a2d28c 100644
--- a/ldap/schema/01core389.ldif
+++ b/ldap/schema/01core389.ldif
@@ -297,6 +297,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2302 NAME 'nsslapd-listen-backlog-size'
attributeTypes: ( 2.16.840.1.113730.3.1.2303 NAME 'nsslapd-ignore-time-skew' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2304 NAME 'nsslapd-dynamic-plugins' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2305 NAME 'nsslapd-moddn-aci' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2306 NAME 'nsslapd-return-default-opattr' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE directoryOperation X-ORIGIN 'Netscape Directory Server' )
#
# objectclasses
#
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index a10dfae..7b45e75 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -1157,6 +1157,8 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_
char *current_type_name = NULL;
int rewrite_rfc1274 = 0;
int vattr_flags = 0;
+ char *dn = NULL;
+ char **default_attrs = NULL;
if(real_attrs_only == SLAPI_SEND_VATTR_FLAG_REALONLY)
vattr_flags = SLAPI_REALATTRS_ONLY;
@@ -1193,6 +1195,10 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_
rewrite_rfc1274 = config_get_rewrite_rfc1274();
+ dn = slapi_entry_get_dn_const(e);
+ if (dn == NULL || *dn == '\0' ) {
+ default_attrs = slapi_entry_attr_get_charray(e, CONFIG_RETURN_DEFAULT_OPATTR);
+ }
/* Send the attrs back to the client */
for (current_type = vattr_typethang_first(typelist); current_type; current_type = vattr_typethang_next(current_type) ) {
@@ -1224,6 +1230,14 @@ static int send_all_attrs(Slapi_Entry *e,char **attrs,Slapi_Operation *op,Slapi_
break;
}
}
+ if (!sendit && default_attrs) {
+ for ( i = 0; default_attrs != NULL && default_attrs[i] != NULL; i++ ) {
+ if ( slapi_attr_type_cmp( default_attrs[i], current_type_name, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) {
+ sendit = 1;
+ break;
+ }
+ }
+ }
}
/*
* it's a user attribute. send it.
@@ -1324,6 +1338,9 @@ exit:
if (NULL != typelist) {
slapi_vattr_attrs_free(&typelist,typelist_flags);
}
+ if (NULL != default_attrs) {
+ slapi_ch_free((void**)&default_attrs);
+ }
return rc;
}
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index f807d8d..642f3b2 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2150,6 +2150,7 @@ typedef struct _slapdEntryPoints {
#define CONFIG_PLUGIN_LOGGING "nsslapd-plugin-logging"
#define CONFIG_LISTEN_BACKLOG_SIZE "nsslapd-listen-backlog-size"
#define CONFIG_DYNAMIC_PLUGINS "nsslapd-dynamic-plugins"
+#define CONFIG_RETURN_DEFAULT_OPATTR "nsslapd-return-default-opattr"
/* getenv alternative */
#define CONFIG_MALLOC_MXFAST "nsslapd-malloc-mxfast"
9 years, 5 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/ldbm_add.c | 13 ++++++++
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 12 +++----
ldap/servers/slapd/back-ldbm/ldbm_modify.c | 38 +++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 1
4 files changed, 58 insertions(+), 6 deletions(-)
New commits:
commit ac8ada32de4bcc3dfd0a3e2958cefd91f98c4170
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Apr 16 15:21:21 2014 -0400
Ticket 47782 - Parent numbordinate count can be incorrectly updated if an error occurs
Bug Description: When adding and deleting entries there is a small chance that the modified
parent entry(numbsubordinates) could be replaced in the entry cache, even
if the operation fails.
Fix Description: For deletes we can simply move the cache entry switching to a safe location,
but for adds we need to unswitch the parent's entry in the cache.
https://fedorahosted.org/389/ticket/47782
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 554822c..0ade23c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -117,6 +117,7 @@ ldbm_back_add( Slapi_PBlock *pb )
int is_ruv = 0; /* True if the current entry is RUV */
CSN *opcsn = NULL;
entry_address addr = {0};
+ int parent_switched = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -974,6 +975,7 @@ ldbm_back_add( Slapi_PBlock *pb )
{
/* switch the parent entry copy into play */
modify_switch_entries( &parent_modify_c,be);
+ parent_switched = 1;
}
if (ruv_c_init) {
@@ -1046,6 +1048,17 @@ error_return:
dblayer_remember_disk_filled(li);
ldbm_nasty("Add",80,rc);
disk_full = 1;
+ } else if (0 == rc) {
+ rc = SLAPI_FAIL_GENERAL;
+ }
+
+ if (parent_switched){
+ /*
+ * Restore the old parent entry, switch the new with the original.
+ * Otherwise the numsubordinate count will be off, and could later
+ * be written to disk.
+ */
+ modify_unswitch_entries( &parent_modify_c,be);
}
diskfull_return:
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 7c036df..c80d75a 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -1095,12 +1095,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
CACHE_RETURN(&inst->inst_cache, &e);
e = NULL;
}
-
- if (parent_found)
- {
- /* Replace the old parent entry with the newly modified one */
- modify_switch_entries( &parent_modify_c,be);
- }
if (ruv_c_init) {
if (modify_switch_entries(&ruv_c, be) != 0 ) {
@@ -1112,6 +1106,12 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
}
+ if (parent_found)
+ {
+ /* Replace the old parent entry with the newly modified one */
+ modify_switch_entries( &parent_modify_c,be);
+ }
+
rc= 0;
goto common_return;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index b8b6114..be47fcc 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -122,6 +122,44 @@ int modify_switch_entries(modify_context *mc,backend *be)
return ret;
}
+/*
+ * Switch the new with the old(original) - undoing modify_switch_entries()
+ * This expects modify_term() to be called next, as the old "new" entry
+ * is now gone(replaced by the original entry).
+ */
+int
+modify_unswitch_entries(modify_context *mc,backend *be)
+{
+ struct backentry *tmp_be;
+ ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
+ int ret = 0;
+
+ if (mc->old_entry!=NULL && mc->new_entry!=NULL) {
+ /* switch the entries, and reset the new, new, entry */
+ tmp_be = mc->new_entry;
+ mc->new_entry = mc->old_entry;
+ mc->new_entry->ep_state = 0;
+ mc->new_entry->ep_refcnt = 0;
+ mc->new_entry_in_cache = 0;
+ mc->old_entry = tmp_be;
+
+ ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
+ if (ret == 0) {
+ /*
+ * The new entry was originally locked, so since we did the
+ * switch we need to unlock the "new" entry, and return the
+ * "old" one. modify_term() will then return the "new" entry.
+ */
+ cache_unlock_entry(&inst->inst_cache, mc->new_entry);
+ CACHE_RETURN( &(inst->inst_cache), &(mc->old_entry) );
+ mc->new_entry_in_cache = 1;
+ mc->old_entry = NULL;
+ }
+ }
+
+ return ret;
+}
+
/* This routine does that part of a modify operation which involves
updating the on-disk data: updates idices, id2entry.
Copes properly with DB_LOCK_DEADLOCK. The caller must be able to cope with
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index ee30c45..02b261b 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -350,6 +350,7 @@ void modify_init(modify_context *mc,struct backentry *old_entry);
int modify_apply_mods(modify_context *mc, Slapi_Mods *smods);
int modify_term(modify_context *mc,backend *be);
int modify_switch_entries(modify_context *mc,backend *be);
+int modify_unswitch_entries(modify_context *mc,backend *be);
int modify_apply_mods_ignore_error(modify_context *mc, Slapi_Mods *smods, int error);
/*
9 years, 5 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/ldbm_add.c | 10 ++++++
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 12 +++----
ldap/servers/slapd/back-ldbm/ldbm_modify.c | 38 +++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 1
4 files changed, 55 insertions(+), 6 deletions(-)
New commits:
commit cef6ae45454ee54f6f97f38eeffe56f46e0648b5
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Apr 16 15:21:21 2014 -0400
Ticket 47782 - Parent numbordinate count can be incorrectly updated if an error occurs
Bug Description: When adding and deleting entries there is a small chance that the modified
parent entry(numbsubordinates) could be replaced in the entry cache, even
if the operation fails.
Fix Description: For deletes we can simply move the cache entry switching to a safe location,
but for adds we need to unswitch the parent's entry in the cache.
https://fedorahosted.org/389/ticket/47782
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 2079892800843d1541a8f712d0b1395f75919ee9)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index e5b9eeb..3dcceff 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -117,6 +117,7 @@ ldbm_back_add( Slapi_PBlock *pb )
CSN *opcsn = NULL;
entry_address addr = {0};
int not_an_error = 0;
+ int parent_switched = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -1018,6 +1019,7 @@ ldbm_back_add( Slapi_PBlock *pb )
{
/* switch the parent entry copy into play */
modify_switch_entries( &parent_modify_c,be);
+ parent_switched = 1;
}
if (ruv_c_init) {
@@ -1097,6 +1099,14 @@ error_return:
} else if (0 == rc) {
rc = SLAPI_FAIL_GENERAL;
}
+ if (parent_switched){
+ /*
+ * Restore the old parent entry, switch the new with the original.
+ * Otherwise the numsubordinate count will be off, and could later
+ * be written to disk.
+ */
+ modify_unswitch_entries( &parent_modify_c,be);
+ }
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 31249c7..792d424 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -1155,12 +1155,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
CACHE_RETURN(&inst->inst_cache, &e);
e = NULL;
}
-
- if (parent_found)
- {
- /* Replace the old parent entry with the newly modified one */
- modify_switch_entries( &parent_modify_c,be);
- }
if (ruv_c_init) {
if (modify_switch_entries(&ruv_c, be) != 0 ) {
@@ -1172,6 +1166,12 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
}
+ if (parent_found)
+ {
+ /* Replace the old parent entry with the newly modified one */
+ modify_switch_entries( &parent_modify_c,be);
+ }
+
rc= 0;
goto common_return;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index de5dd17..0f01b2f 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -122,6 +122,44 @@ int modify_switch_entries(modify_context *mc,backend *be)
return ret;
}
+/*
+ * Switch the new with the old(original) - undoing modify_switch_entries()
+ * This expects modify_term() to be called next, as the old "new" entry
+ * is now gone(replaced by the original entry).
+ */
+int
+modify_unswitch_entries(modify_context *mc,backend *be)
+{
+ struct backentry *tmp_be;
+ ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
+ int ret = 0;
+
+ if (mc->old_entry!=NULL && mc->new_entry!=NULL) {
+ /* switch the entries, and reset the new, new, entry */
+ tmp_be = mc->new_entry;
+ mc->new_entry = mc->old_entry;
+ mc->new_entry->ep_state = 0;
+ mc->new_entry->ep_refcnt = 0;
+ mc->new_entry_in_cache = 0;
+ mc->old_entry = tmp_be;
+
+ ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
+ if (ret == 0) {
+ /*
+ * The new entry was originally locked, so since we did the
+ * switch we need to unlock the "new" entry, and return the
+ * "old" one. modify_term() will then return the "new" entry.
+ */
+ cache_unlock_entry(&inst->inst_cache, mc->new_entry);
+ CACHE_RETURN( &(inst->inst_cache), &(mc->old_entry) );
+ mc->new_entry_in_cache = 1;
+ mc->old_entry = NULL;
+ }
+ }
+
+ return ret;
+}
+
/* This routine does that part of a modify operation which involves
updating the on-disk data: updates idices, id2entry.
Copes properly with DB_LOCK_DEADLOCK. The caller must be able to cope with
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 6372f50..d41ce1c 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -361,6 +361,7 @@ void modify_init(modify_context *mc,struct backentry *old_entry);
int modify_apply_mods(modify_context *mc, Slapi_Mods *smods);
int modify_term(modify_context *mc,backend *be);
int modify_switch_entries(modify_context *mc,backend *be);
+int modify_unswitch_entries(modify_context *mc,backend *be);
int modify_apply_mods_ignore_error(modify_context *mc, Slapi_Mods *smods, int error);
/*
9 years, 5 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/ldbm_add.c | 10 ++++++
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 12 +++----
ldap/servers/slapd/back-ldbm/ldbm_modify.c | 38 +++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 1
4 files changed, 55 insertions(+), 6 deletions(-)
New commits:
commit 4ddc6dc2dd2e6336f8aa61f8523b46172cc971b4
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Apr 16 15:21:21 2014 -0400
Ticket 47782 - Parent numbordinate count can be incorrectly updated if an error occurs
Bug Description: When adding and deleting entries there is a small chance that the modified
parent entry(numbsubordinates) could be replaced in the entry cache, even
if the operation fails.
Fix Description: For deletes we can simply move the cache entry switching to a safe location,
but for adds we need to unswitch the parent's entry in the cache.
https://fedorahosted.org/389/ticket/47782
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 2079892800843d1541a8f712d0b1395f75919ee9)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 7834b40..9087a62 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -117,6 +117,7 @@ ldbm_back_add( Slapi_PBlock *pb )
CSN *opcsn = NULL;
entry_address addr = {0};
int not_an_error = 0;
+ int parent_switched = 0;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &e );
@@ -1018,6 +1019,7 @@ ldbm_back_add( Slapi_PBlock *pb )
{
/* switch the parent entry copy into play */
modify_switch_entries( &parent_modify_c,be);
+ parent_switched = 1;
}
if (ruv_c_init) {
@@ -1097,6 +1099,14 @@ error_return:
} else if (0 == rc) {
rc = SLAPI_FAIL_GENERAL;
}
+ if (parent_switched){
+ /*
+ * Restore the old parent entry, switch the new with the original.
+ * Otherwise the numsubordinate count will be off, and could later
+ * be written to disk.
+ */
+ modify_unswitch_entries( &parent_modify_c,be);
+ }
diskfull_return:
if (disk_full) {
rc= return_on_disk_full(li);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index a858fa0..678580c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -1155,12 +1155,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
CACHE_RETURN(&inst->inst_cache, &e);
e = NULL;
}
-
- if (parent_found)
- {
- /* Replace the old parent entry with the newly modified one */
- modify_switch_entries( &parent_modify_c,be);
- }
if (ruv_c_init) {
if (modify_switch_entries(&ruv_c, be) != 0 ) {
@@ -1172,6 +1166,12 @@ ldbm_back_delete( Slapi_PBlock *pb )
}
}
+ if (parent_found)
+ {
+ /* Replace the old parent entry with the newly modified one */
+ modify_switch_entries( &parent_modify_c,be);
+ }
+
rc= 0;
goto common_return;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
index 8bbeae0..f8fb168 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
@@ -122,6 +122,44 @@ int modify_switch_entries(modify_context *mc,backend *be)
return ret;
}
+/*
+ * Switch the new with the old(original) - undoing modify_switch_entries()
+ * This expects modify_term() to be called next, as the old "new" entry
+ * is now gone(replaced by the original entry).
+ */
+int
+modify_unswitch_entries(modify_context *mc,backend *be)
+{
+ struct backentry *tmp_be;
+ ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
+ int ret = 0;
+
+ if (mc->old_entry!=NULL && mc->new_entry!=NULL) {
+ /* switch the entries, and reset the new, new, entry */
+ tmp_be = mc->new_entry;
+ mc->new_entry = mc->old_entry;
+ mc->new_entry->ep_state = 0;
+ mc->new_entry->ep_refcnt = 0;
+ mc->new_entry_in_cache = 0;
+ mc->old_entry = tmp_be;
+
+ ret = cache_replace(&(inst->inst_cache), mc->old_entry, mc->new_entry);
+ if (ret == 0) {
+ /*
+ * The new entry was originally locked, so since we did the
+ * switch we need to unlock the "new" entry, and return the
+ * "old" one. modify_term() will then return the "new" entry.
+ */
+ cache_unlock_entry(&inst->inst_cache, mc->new_entry);
+ CACHE_RETURN( &(inst->inst_cache), &(mc->old_entry) );
+ mc->new_entry_in_cache = 1;
+ mc->old_entry = NULL;
+ }
+ }
+
+ return ret;
+}
+
/* This routine does that part of a modify operation which involves
updating the on-disk data: updates idices, id2entry.
Copes properly with DB_LOCK_DEADLOCK. The caller must be able to cope with
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index f46b2e6..f602b2b 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -365,6 +365,7 @@ void modify_init(modify_context *mc,struct backentry *old_entry);
int modify_apply_mods(modify_context *mc, Slapi_Mods *smods);
int modify_term(modify_context *mc,backend *be);
int modify_switch_entries(modify_context *mc,backend *be);
+int modify_unswitch_entries(modify_context *mc,backend *be);
int modify_apply_mods_ignore_error(modify_context *mc, Slapi_Mods *smods, int error);
/*
9 years, 5 months