From a241f5064e2a08c4248e57e0dfadbc2e997ecad5 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Wed, 16 Apr 2014 15:04:36 -0700 Subject: [PATCH 203/225] 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@redhat.com (Thank you, Rich!) (cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52) (cherry picked from commit 821297df835b7d5235d66b592613c89d991d4049) (cherry picked from commit e97f2b8f2a42d4ceca4020614fd7388e4e319bab) (cherry picked from commit 5e45f459bbad53e63b8ff8308a934559840e23df) --- ldap/servers/slapd/entry.c | 2 +- ldap/servers/slapd/valueset.c | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index d9226af..a5a21e0 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 ); -- 1.8.1.4