From fe49ea4a2342d4957664bde0898209794d033269 Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Mon, 3 Feb 2014 13:43:56 -0500
Subject: [PATCH] Ticket 47618 - Enable normalized DN cache by default

Enable the normalized DN cache by default as there is a performance boost,
especially with roles.  Enable cache for upgrades as well.

https://fedorahosted.org/389/ticket/47618

Reviewed by: ?
---
 Makefile.am                                |    1 +
 Makefile.in                                |    1 +
 ldap/admin/src/scripts/50updateconfig.ldif |   10 ++++++++++
 ldap/admin/src/scripts/DSUpdate.pm.in      |    2 ++
 ldap/ldif/template-dse.ldif.in             |    2 +-
 ldap/servers/slapd/libglobs.c              |    2 +-
 6 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 ldap/admin/src/scripts/50updateconfig.ldif

diff --git a/Makefile.am b/Makefile.am
index 26174bf..60c3d3c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -574,6 +574,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/81changelog.pl \
 	ldap/admin/src/scripts/90subtreerename.pl \
 	ldap/admin/src/scripts/91subtreereindex.pl \
+	ldap/admin/src/scripts/50updateconfig.ldif \
 	ldap/admin/src/scripts/dnaplugindepends.ldif
 
 update_SCRIPTS = ldap/admin/src/scripts/exampleupdate.sh
diff --git a/Makefile.in b/Makefile.in
index 3b6e477..780227f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1982,6 +1982,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/81changelog.pl \
 	ldap/admin/src/scripts/90subtreerename.pl \
 	ldap/admin/src/scripts/91subtreereindex.pl \
+	ldap/admin/src/scripts/50updateconfig.ldif \
 	ldap/admin/src/scripts/dnaplugindepends.ldif
 
 update_SCRIPTS = ldap/admin/src/scripts/exampleupdate.sh
diff --git a/ldap/admin/src/scripts/50updateconfig.ldif b/ldap/admin/src/scripts/50updateconfig.ldif
new file mode 100644
index 0000000..719d4a8
--- /dev/null
+++ b/ldap/admin/src/scripts/50updateconfig.ldif
@@ -0,0 +1,10 @@
+#
+# Updates for the cn=config entry
+#
+
+# Enable the Normalized DN cache
+dn: cn=config
+changetype: modify
+replace: nsslapd-ndn-cache-enabled
+nsslapd-ndn-cache-enabled: on
+
diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in b/ldap/admin/src/scripts/DSUpdate.pm.in
index ecdfeb7..208edfe 100644
--- a/ldap/admin/src/scripts/DSUpdate.pm.in
+++ b/ldap/admin/src/scripts/DSUpdate.pm.in
@@ -378,6 +378,8 @@ sub updateDSInstance {
                 push @ldiffiles, "$inf->{General}->{prefix}@templatedir@/template-dnaplugin.ldif";
                 push @ldiffiles, $inf->{General}->{prefix} . $DS_UPDATE_PATH . "/dnaplugindepends.ldif";
             }
+            push @ldiffiles, $inf->{General}->{prefix} . $DS_UPDATE_PATH . "/50updateconfig.ldif";
+
             for my $ldiffile (@ldiffiles) {
                 my @localerrs = processUpdate($ldiffile, $inf, $configdir, $stage,
                                               $inst, $dseldif, $conn);
diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in
index af176e9..cc2efe7 100644
--- a/ldap/ldif/template-dse.ldif.in
+++ b/ldap/ldif/template-dse.ldif.in
@@ -56,7 +56,7 @@ nsslapd-rootdn: %rootdn%
 nsslapd-rootpw: %ds_passwd%
 nsslapd-maxdescriptors: 1024
 nsslapd-max-filter-nest-level: 40
-nsslapd-ndn-cache-enabled: off
+nsslapd-ndn-cache-enabled: on
 nsslapd-sasl-mapping-fallback: off
 
 dn: cn=features,cn=config
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 7ef06a8..bea8b2c 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1507,7 +1507,7 @@ FrontendConfig_init () {
   cfg->disk_threshold = 2097152;  /* 2 mb */
   cfg->disk_grace_period = 60; /* 1 hour */
   init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
-  init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
+  init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_ON;
   cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
   init_sasl_mapping_fallback = cfg->sasl_mapping_fallback = LDAP_OFF;
   cfg->ignore_vattrs = LDAP_OFF;
-- 
1.7.1

