From 438005440f6cb6014d94eea6d40df8495abbbe42 Mon Sep 17 00:00:00 2001 From: kkuznetsov Date: Mon, 4 Apr 2005 12:54:34 +0000 Subject: [PATCH] Allow setting TCP_NODELAY socket option in Classic Server and make if default true on both arhitecture. --- builds/install/misc/firebird.conf | 3 +-- src/common/config/config.cpp | 2 +- src/remote/inet.cpp | 25 +++++++++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/builds/install/misc/firebird.conf b/builds/install/misc/firebird.conf index 82f5f238e4..53e904d3d8 100644 --- a/builds/install/misc/firebird.conf +++ b/builds/install/misc/firebird.conf @@ -341,8 +341,7 @@ # Either enables or disables Nagle algorithm (TCP_NODELAY option of # socket) of the socket connection. # -# Note: Currently this is only active for super server, classic -# server needs an extra wrapper program. +# Note: Currently is a default for classic and super servers. # # Type: boolean # diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index cdf67fd2ec..4f3877903d 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -65,7 +65,7 @@ const ConfigImpl::ConfigEntry ConfigImpl::entries[] = {TYPE_INTEGER, "CpuAffinityMask", (ConfigValue) 1}, {TYPE_BOOLEAN, "OldParameterOrdering", (ConfigValue) false}, {TYPE_INTEGER, "TcpRemoteBufferSize", (ConfigValue) 8192}, // bytes - {TYPE_BOOLEAN, "TcpNoNagle", (ConfigValue) false}, + {TYPE_BOOLEAN, "TcpNoNagle", (ConfigValue) true}, #ifdef SUPERSERVER {TYPE_INTEGER, "DefaultDbCachePages", (ConfigValue) 2048}, // pages #else diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index a50ee45e09..7293e8a957 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -38,6 +38,7 @@ * * 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define * 2002.10.30 Sean Leyne - Code Cleanup, removed obsolete "SUN3_3" port + * 2005.04.01 Konstantin Kuznetsov - allow setting NoNagle option in Classic * */ @@ -75,14 +76,14 @@ #include #endif +#include + + #ifdef SUPERSERVER #ifdef WIN_NT #define FD_SETSIZE 1024 #endif -#ifdef SET_TCP_NO_DELAY -#include -#endif #endif /* SUPERSERVER */ @@ -1024,6 +1025,7 @@ rem_port* INET_server(int sock) * established. Set up port block with the appropriate socket. * **************************************/ + int n = 0; #ifdef VMS ISC_tcp_setup(ISC_wait, gds__completion_ast); #endif @@ -1032,8 +1034,23 @@ rem_port* INET_server(int sock) port->port_handle = (HANDLE) sock; int optval = 1; - setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, + n = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (SCHAR *) & optval, sizeof(optval)); + if (n==-1) { + gds__log("inet server err: setting KEEPALIVE socket option \n"); + } + + if (Config::getTcpNoNagle()) { + n = setsockopt(sock, SOL_SOCKET,TCP_NODELAY, + (SCHAR *) &optval, sizeof(optval)); +#ifdef DEBUG + gds__log("inet log: disabled Nagle algorithm \n"); +#endif + if (n == -1) { + gds__log("inet server err: setting NODELAY socket option \n"); + } + } + return port; }