Browse Source

Ticket #565 - turbo mode and replication - allow disable of turbo mode

https://fedorahosted.org/389/ticket/565
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Add nsslapd-enable-turbo-mode configuration attribute.
This allows the user to disable turbo mode.  The default for this setting
is on.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config parameter
Rich Megginson 12 years ago
parent
commit
1c0c6b135a

+ 10 - 6
ldap/servers/slapd/connection.c

@@ -2253,12 +2253,16 @@ connection_threadmain()
 #if defined(DB_PERF_TURBO)
 		/* If it's been a while since we last did it ... */
 		if (curtime - conn->c_private->previous_count_check_time > CONN_TURBO_CHECK_INTERVAL) {
-			int new_turbo_flag = 0;
-			/* Check the connection's activity level */
-			connection_check_activity_level(conn);
-			/* And if appropriate, change into or out of turbo mode */
-			connection_enter_leave_turbo(conn,thread_turbo_flag,&new_turbo_flag);
-			thread_turbo_flag = new_turbo_flag;
+			if (config_get_enable_turbo_mode()) {
+				int new_turbo_flag = 0;
+				/* Check the connection's activity level */
+				connection_check_activity_level(conn);
+				/* And if appropriate, change into or out of turbo mode */
+				connection_enter_leave_turbo(conn,thread_turbo_flag,&new_turbo_flag);
+				thread_turbo_flag = new_turbo_flag;
+			} else {
+				thread_turbo_flag = 0;
+			}
 		}
 
 		/* turn off turbo mode immediately if any pb waiting in global queue */

+ 33 - 1
ldap/servers/slapd/libglobs.c

@@ -256,6 +256,7 @@ slapi_onoff_t init_disk_preserve_logging;
 slapi_onoff_t init_ndn_cache_enabled;
 slapi_onoff_t init_sasl_mapping_fallback;
 slapi_onoff_t init_return_orig_type;
+slapi_onoff_t init_enable_turbo_mode;
 #ifdef MEMPOOL_EXPERIMENTAL
 slapi_onoff_t init_mempool_switch;
 #endif
@@ -1043,7 +1044,11 @@ static struct config_get_and_set {
 	{CONFIG_SEARCH_RETURN_ORIGINAL_TYPE, config_set_return_orig_type_switch,
 		NULL, 0,
 		(void**)&global_slapdFrontendConfig.return_orig_type,
-		CONFIG_ON_OFF, (ConfigGetFunc)config_get_return_orig_type_switch, &init_return_orig_type}
+		CONFIG_ON_OFF, (ConfigGetFunc)config_get_return_orig_type_switch, &init_return_orig_type},
+	{CONFIG_ENABLE_TURBO_MODE, config_set_enable_turbo_mode,
+	        NULL, 0,
+	        (void**)&global_slapdFrontendConfig.enable_turbo_mode,
+	        CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_turbo_mode, &init_enable_turbo_mode}
 #ifdef MEMPOOL_EXPERIMENTAL
 	,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
 		NULL, 0,
@@ -1478,6 +1483,7 @@ FrontendConfig_init () {
   cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
   cfg->unhashed_pw_switch = SLAPD_UNHASHED_PW_ON;
   init_return_orig_type = cfg->return_orig_type = LDAP_OFF;
+  init_enable_turbo_mode = cfg->enable_turbo_mode = LDAP_ON;
 
 #ifdef MEMPOOL_EXPERIMENTAL
   init_mempool_switch = cfg->mempool_switch = LDAP_ON;
@@ -6886,6 +6892,19 @@ config_set_unhashed_pw_switch(const char *attrname, char *value,
     }
 
     CFG_UNLOCK_WRITE(slapdFrontendConfig);
+
+    return retVal;
+}
+
+int
+config_get_enable_turbo_mode(void)
+{
+    int retVal;
+    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+    CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
+    retVal = (int)slapdFrontendConfig->enable_turbo_mode;
+    CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
+
     return retVal;
 }
 
@@ -6907,6 +6926,19 @@ config_get_unhashed_pw_switch()
     return retVal;
 }
 
+int
+config_set_enable_turbo_mode( const char *attrname, char *value,
+                            char *errorbuf, int apply )
+{
+    int retVal = LDAP_SUCCESS;
+    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+    retVal = config_set_onoff(attrname, value,
+                              &(slapdFrontendConfig->enable_turbo_mode),
+                              errorbuf, apply);
+    return retVal;
+}
+
 /*
  * This function is intended to be used from the dse code modify callback.  It
  * is "optimized" for that case because it takes a berval** of values, which is

+ 2 - 0
ldap/servers/slapd/proto-slap.h

@@ -567,6 +567,8 @@ int config_set_sasl_mapping_fallback(const char *attrname, char *value, char *er
 int config_get_sasl_mapping_fallback();
 int config_get_unhashed_pw_switch();
 int config_get_sasl_maxbufsize();
+int config_get_enable_turbo_mode();
+int config_set_enable_turbo_mode(const char *attrname, char *value, char *errorbuf, int apply);
 
 PLHashNumber hashNocaseString(const void *key);
 PRIntn hashNocaseCompare(const void *v1, const void *v2);

+ 2 - 0
ldap/servers/slapd/slap.h

@@ -2075,6 +2075,7 @@ typedef struct _slapdEntryPoints {
 #define CONFIG_SASL_MAPPING_FALLBACK "nsslapd-sasl-mapping-fallback"
 #define CONFIG_SASL_MAXBUFSIZE "nsslapd-sasl-max-buffer-size"
 #define CONFIG_SEARCH_RETURN_ORIGINAL_TYPE "nsslapd-search-return-original-type-switch"
+#define CONFIG_ENABLE_TURBO_MODE "nsslapd-enable-turbo-mode"
 
 #ifdef MEMPOOL_EXPERIMENTAL
 #define CONFIG_MEMPOOL_SWITCH_ATTRIBUTE "nsslapd-mempool"
@@ -2317,6 +2318,7 @@ typedef struct _slapdFrontendConfig {
   Slapi_Counter *ignore_vattrs;
   Slapi_Counter *sasl_mapping_fallback;
   slapi_onoff_t unhashed_pw_switch;	/* switch to on/off/nolog unhashed pw */
+  slapi_onoff_t enable_turbo_mode;
 } slapdFrontendConfig_t;
 
 /* possible values for slapdFrontendConfig_t.schemareplace */