[#2720] Check if /proc/sys/net/core/somaxconn exists before try to parse it
Motivation: As /proc/sys/net/core/somaxconn does not exists on non-linux platforms you see a noisy stacktrace when debug level is enabled while the static method of NetUtil is executed. Modifications: Check if the file exists before try to parse it. Result: Less noisy logging on non-linux platforms.
This commit is contained in:
parent
3c4321ce43
commit
1f95e5db4c
@ -20,6 +20,7 @@ import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
@ -180,6 +181,8 @@ public final class NetUtil {
|
||||
|
||||
// Determine the default somaxconn (server socket backlog) value of the platform.
|
||||
int somaxconn = 3072;
|
||||
File file = new File("/proc/sys/net/core/somaxconn");
|
||||
if (file.exists()) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader("/proc/sys/net/core/somaxconn"));
|
||||
@ -196,6 +199,9 @@ public final class NetUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.debug("/proc/sys/net/core/somaxconn not exists. Use default-value: {}", somaxconn);
|
||||
}
|
||||
|
||||
SOMAXCONN = somaxconn;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user