Skip to content

Commit

Permalink
check somaxconn on linux only
Browse files Browse the repository at this point in the history
  • Loading branch information
georgew5656 committed Jan 5, 2024
1 parent 185978d commit 4e7ade5
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.inject.multibindings.Multibinder;
import com.sun.jersey.guice.JerseyServletModule;
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import org.apache.commons.lang3.SystemUtils;
import org.apache.druid.guice.Jerseys;
import org.apache.druid.guice.JsonConfigProvider;
import org.apache.druid.guice.LazySingleton;
Expand Down Expand Up @@ -497,17 +498,19 @@ private static int getMaxJettyAcceptorsSelectorsNum(DruidNode druidNode)

private static int getTCPAcceptQueueSize()
{
try {
BufferedReader in = Files.newBufferedReader(Paths.get("/proc/sys/net/core/somaxconn"));
String acceptQueueSize = in.readLine();
if (acceptQueueSize != null) {
return Integer.parseInt(acceptQueueSize);
if (SystemUtils.IS_OS_LINUX) {
try {
BufferedReader in = Files.newBufferedReader(Paths.get("/proc/sys/net/core/somaxconn"));
String acceptQueueSize = in.readLine();
if (acceptQueueSize != null) {
return Integer.parseInt(acceptQueueSize);
}
}
catch (Exception e) {
log.warn("Unable to read /proc/sys/net/core/somaxconn, falling back to default value for TCP accept queue size");
}
}
catch (Exception e) {
log.warn("Unable to read /proc/sys/net/core/somaxconn, falling back to default value for TCP accept queue size");
}
return 128; // Default value of net.core.somaxconn on Linux
return 128; // Default value of net.core.somaxconn
}

@Provides
Expand Down

0 comments on commit 4e7ade5

Please sign in to comment.