summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--configure.ac2
-rw-r--r--slapi-nis.spec6
-rw-r--r--src/back-sch.c82
4 files changed, 63 insertions, 29 deletions
diff --git a/NEWS b/NEWS
index 247cc8f..4b11968 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+0.23 * Speed up building compat entries with attributes with thousands
+ of literal values (#692690).
0.22 * Bug fixes.
* Learn to build against either mozldap or openldap when building
for dirsrv servers.
diff --git a/configure.ac b/configure.ac
index e75de40..19f8d9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(slapi-nis,0.22)
+AC_INIT(slapi-nis,0.23)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(foreign)
LT_INIT
diff --git a/slapi-nis.spec b/slapi-nis.spec
index f4f6ee5..76b413e 100644
--- a/slapi-nis.spec
+++ b/slapi-nis.spec
@@ -5,7 +5,7 @@
%endif
Name: slapi-nis
-Version: 0.22
+Version: 0.23
Release: 1%{?dist}
Summary: NIS Server and Schema Compatibility plugins for Directory Server
Group: System Environment/Daemons
@@ -57,6 +57,10 @@ rm -rf $RPM_BUILD_ROOT
%{_sbindir}/nisserver-plugin-defs
%changelog
+* Thu Mar 31 2011 Nalin Dahyabhai <nalin@redhat.com> - 0.23-1
+- speed up building compat entries with attributes with thousands of literal
+ values (#692690)
+
* Thu Jan 6 2011 Nalin Dahyabhai <nalin@redhat.com> - 0.22-1
- fix a number of scanner-uncovered defects
diff --git a/src/back-sch.c b/src/back-sch.c
index 528225b..f9425fd 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -265,14 +265,14 @@ void
backend_set_entry(Slapi_Entry *e, struct backend_set_data *data)
{
char *dn, *rdn, *ndn, *ldif, *plugin_id, *keys[2], *values[2], **ava;
- char *val;
+ char *attr, *val;
unsigned int rdn_len, value_len, *ava_lens;
const char *rdnstr;
- int len, i, j;
+ int len, i, j, k, count;
Slapi_Entry *entry;
Slapi_DN *e_dn, *sdn;
Slapi_RDN *srdn;
- Slapi_Value *value[2];
+ Slapi_Value **value;
plugin_id = data->common.state->plugin_desc->spd_id;
e_dn = slapi_entry_get_sdn(e);
@@ -306,8 +306,6 @@ backend_set_entry(Slapi_Entry *e, struct backend_set_data *data)
time(NULL), 0);
/* Iterate through the set of attributes. */
if (data->attribute_format != NULL) {
- value[0] = slapi_value_new();
- value[1] = NULL;
for (i = 0; data->attribute_format[i] != NULL; i++) {
/* Expand the format specifier into a list. */
ava_lens = NULL;
@@ -321,34 +319,64 @@ backend_set_entry(Slapi_Entry *e, struct backend_set_data *data)
&data->common.ref_attr_list,
&data->common.inref_attr_list,
&ava_lens);
- if ((ava != NULL) &&
- (ava_lens != NULL) &&
- (value[0] != NULL)) {
+ if ((ava != NULL) && (ava_lens != NULL)) {
+ /* Count the values. */
+ count = 0;
for (j = 0; ava[j] != NULL; j++) {
- /* Assume attribute=value. */
- val = memchr(ava[j], '=',
- ava_lens[j]);
- /* Skip over anything that didn't have
- * a '=' or that produced an empty
- * value. */
- if ((val != NULL) &&
- (ava_lens[j] > val + 1 - ava[j])) {
- *val = '\0';
- slapi_value_set(value[0],
- val + 1,
- ava_lens[j] -
- (val + 1 -
- ava[j]));
- slapi_entry_merge_values_sv(entry,
- ava[j],
- value);
- *val = '=';
+ count++;
+ }
+ /* Create the value array. */
+ value = malloc((count + 1) * sizeof(Slapi_Value *));
+ if (value != NULL) {
+ attr = NULL;
+ len = 0;
+ k = 0;
+ for (j = 0; ava[j] != NULL; j++) {
+ /* Assume attribute=value. */
+ val = memchr(ava[j], '=',
+ ava_lens[j]);
+ /* Skip over anything that didn't have
+ * a '=' or that produced an empty
+ * value. */
+ if ((val != NULL) &&
+ (ava_lens[j] > val + 1 - ava[j])) {
+ /* Add a new value. */
+ value[k] = slapi_value_new();
+ if (value[k] != NULL) {
+ /* Set the value. */
+ attr = ava[j];
+ len = ava_lens[j];
+ slapi_value_set(value[k],
+ val + 1,
+ ava_lens[j] -
+ (val + 1 -
+ ava[j]));
+ k++;
+ }
+ }
+ }
+ value[k] = NULL;
+ if ((k > 0) && (attr != NULL) && (len > 0)) {
+ /* We assumed attribute=value when we
+ * saved this particular value. */
+ val = memchr(attr, '=', len);
+ if (val != NULL) {
+ *val = '\0';
+ slapi_entry_merge_values_sv(entry,
+ attr,
+ value);
+ *val = '=';
+ }
+ }
+ /* Clean up the values. */
+ for (j = 0; j < k; j++) {
+ slapi_value_free(&value[k]);
}
+ free(value);
}
}
format_free_data_set(ava, ava_lens);
}
- slapi_value_free(&value[0]);
}
/* Try to make the entry look "right". */
if (!slapi_entry_rdn_values_present(entry)) {