ldap/servers/slapd/connection.c | 36 +++++++++++++++++-------------------
ldap/servers/slapd/daemon.c | 6 ------
ldap/servers/slapd/libglobs.c | 5 +++++
3 files changed, 22 insertions(+), 25 deletions(-)
New commits:
commit 37f338cec1e84292cf2e5a0db23f36180ff27ef9
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Mar 19 16:43:44 2013 -0600
Ticket #633 - allow nsslapd-nagle to be disabled, and also tcp cork
https://fedorahosted.org/389/ticket/633
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Instead of hard-coded enable_nagle = 1 in the connection
code, use the server config nsslapd-nagle setting. The default is on
on linux. Also make the tcp cork in connection_dispatch_operation() depend
on the nagle setting - if nagle is enabled, then enable tcp cork, otherwise,
disable tcp cork too.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: Yes - document new config parameter
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 26ac20b..31fc543 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -499,7 +499,10 @@ connection_dispatch_operation(Connection *conn, Operation *op,
Slapi_PBlock *pb)
{
int minssf = config_get_minssf();
int minssf_exclude_rootdse = 0;
-
+#ifdef TCP_CORK
+ int enable_nagle = config_get_nagle();
+ int pop_cork = 0;
+#endif
/* Get the effective key length now since the first SSL handshake should be complete */
connection_set_ssl_ssf( conn );
@@ -600,38 +603,33 @@ connection_dispatch_operation(Connection *conn, Operation *op,
Slapi_PBlock *pb)
case LDAP_REQ_SEARCH:
operation_set_type(op,SLAPI_OPERATION_SEARCH);
-
- /* On Linux we can use TCP_CORK to get us 5-10% speed benefit when one entry is returned
*/
- /* Nagle needs to be turned _off_, the default is off on linux, in daemon.c */
-#if defined(LINUX)
- {
- int i = 1;
- int ret = 0;
- /* Set TCP_CORK here but only if this is not LDAPI */
- if(!conn->c_unix_local)
+ /* On Linux we can use TCP_CORK to get us 5-10% speed benefit when one entry is
returned */
+ /* Nagle needs to be turned _on_, the default is _on_ on linux, in daemon.c */
+#ifdef TCP_CORK
+ if (enable_nagle && !conn->c_unix_local)
{
- ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
+ int i = 1;
+ int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
if (ret < 0) {
LDAPDebug(LDAP_DEBUG_ANY, "Failed to set TCP_CORK on connection %" NSPRIu64
"\n",conn->c_connid, 0, 0);
}
+ pop_cork = 1;
}
#endif
-
do_search( pb );
-#if defined(LINUX)
- /* Clear TCP_CORK to flush any unsent data but only if not LDAPI*/
- i = 0;
- if(!conn->c_unix_local)
- {
- ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
+#ifdef TCP_CORK
+ if (pop_cork) {
+ /* Clear TCP_CORK to flush any unsent data but only if not LDAPI*/
+ int i = 0;
+ int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
if (ret < 0) {
LDAPDebug(LDAP_DEBUG_ANY, "Failed to clear TCP_CORK on connection %"
NSPRIu64 "\n",conn->c_connid, 0, 0);
}
}
- }
#endif
+
break;
/* for some strange reason, the console is using this old obsolete
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index abf7611..fa19312 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -3478,11 +3478,6 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int
local )
PRSocketOptionData pr_socketoption;
-#if defined(LINUX)
- /* On Linux we use TCP_CORK so we must enable nagle */
- enable_nagle = 1;
-#endif
-
ns = PR_FileDesc2NativeHandle( *pr_socket );
#if !defined(_WIN32)
@@ -3561,7 +3556,6 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int
local )
} /* else (secure) */
-
if ( !enable_nagle && !local ) {
pr_socketoption.option = PR_SockOpt_NoDelay;
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index fbbb4f9..9780b2e 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -1343,7 +1343,12 @@ FrontendConfig_init () {
#endif /* _WIN32 */
init_accesscontrol = cfg->accesscontrol = LDAP_ON;
+#if defined(LINUX)
+ /* On Linux, by default, we use TCP_CORK so we must enable nagle */
+ init_nagle = cfg->nagle = LDAP_ON;
+#else
init_nagle = cfg->nagle = LDAP_OFF;
+#endif
init_security = cfg->security = LDAP_OFF;
init_ssl_check_hostname = cfg->ssl_check_hostname = LDAP_ON;
init_return_exact_case = cfg->return_exact_case = LDAP_ON;