Reduce the fallback SOMAXCONN value

Related issue: #2407

Motivation:

The current fallback SOMAXCONN value is 3072.  It is way too large
comparing to the default SOMAXCONN value of popular OSes.

Modifications:

Decrease the fallback SOMAXCONN value to 128 or 200 depending on the
current OS

Result:

Saner fallback value
This commit is contained in:
Trustin Lee 2014-08-14 15:40:18 -07:00
parent 1971bd1da6
commit dcd3cadeaa

View File

@ -180,7 +180,10 @@ public final class NetUtil {
LOCALHOST = loopbackAddr;
// Determine the default somaxconn (server socket backlog) value of the platform.
int somaxconn = 3072;
// The known defaults:
// - Windows NT Server 4.0+: 200
// - Linux and Mac OS X: 128
int somaxconn = PlatformDependent.isWindows() ? 200 : 128;
File file = new File("/proc/sys/net/core/somaxconn");
if (file.exists()) {
BufferedReader in = null;