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 2af7a482d9
commit 951ff902bd

View File

@ -180,7 +180,10 @@ public final class NetUtil {
LOCALHOST = loopbackAddr; LOCALHOST = loopbackAddr;
// Determine the default somaxconn (server socket backlog) value of the platform. // 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"); File file = new File("/proc/sys/net/core/somaxconn");
if (file.exists()) { if (file.exists()) {
BufferedReader in = null; BufferedReader in = null;