diff options
author | Andrew Morrow <acm@mongodb.com> | 2017-08-21 18:33:43 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2017-08-23 20:06:04 -0400 |
commit | 0240a830447c54a63c5a925a96544450a08e8831 (patch) | |
tree | ea689fd79430e19aef6d1aa0a965914a403d9c07 | |
parent | 0305aac8b83da67a33d81bebfba0d33e8447dff0 (diff) | |
download | mongo-0240a830447c54a63c5a925a96544450a08e8831.tar.gz |
SERVER-2554 Allow user configuration of the listen depth
-rw-r--r-- | src/mongo/db/server_options.h | 2 | ||||
-rw-r--r-- | src/mongo/db/server_options_helpers.cpp | 9 | ||||
-rw-r--r-- | src/mongo/transport/transport_layer_asio.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/net/listen.cpp | 4 |
4 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index dcf8c52c293..b4efdde5300 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -53,6 +53,8 @@ struct ServerGlobalParams { bool enableIPv6 = false; bool rest = false; // --rest + int listenBacklog = 0; // --listenBacklog, real default is SOMAXCONN + bool indexBuildRetry = true; // --noIndexBuildRetry AtomicBool quiet{false}; // --quiet diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index 753acfd38c1..11a4f37008a 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -199,6 +199,11 @@ Status addGeneralServerOptions(moe::OptionSection* options) { options->addOptionChaining( "net.ipv6", "ipv6", moe::Switch, "enable IPv6 support (disabled by default)"); + options + ->addOptionChaining( + "net.listenBacklog", "listenBacklog", moe::Int, "set socket listen backlog size") + .setDefault(moe::Value(SOMAXCONN)); + options->addOptionChaining( "net.maxIncomingConnections", "maxConns", moe::Int, maxConnInfoBuilder.str().c_str()); @@ -807,6 +812,10 @@ Status storeServerOptions(const moe::Environment& params) { enableIPv6(); } + if (params.count("net.listenBacklog")) { + serverGlobalParams.listenBacklog = params["net.listenBacklog"].as<int>(); + } + if (params.count("net.transportLayer")) { serverGlobalParams.transportLayer = params["net.transportLayer"].as<std::string>(); if (serverGlobalParams.transportLayer != "asio" && diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index 9751c49eddb..4cf0bafdd2c 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -262,7 +262,7 @@ Status TransportLayerASIO::start() { } for (auto& acceptor : _acceptors) { - acceptor.listen(); + acceptor.listen(serverGlobalParams.listenBacklog); _acceptConnection(acceptor); } diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp index c4177fda506..74cae6b771b 100644 --- a/src/mongo/util/net/listen.cpp +++ b/src/mongo/util/net/listen.cpp @@ -249,7 +249,7 @@ void Listener::initAndListen() { SOCKET maxfd = 0; // needed for select() for (unsigned i = 0; i < _socks.size(); i++) { - if (::listen(_socks[i], SOMAXCONN) != 0) { + if (::listen(_socks[i], serverGlobalParams.listenBacklog) != 0) { error() << "listen(): listen() failed " << errnoWithDescription(); return; } @@ -428,7 +428,7 @@ void Listener::initAndListen() { } for (unsigned i = 0; i < _socks.size(); i++) { - if (::listen(_socks[i], SOMAXCONN) != 0) { + if (::listen(_socks[i], serverGlobalParams.listenBacklog) != 0) { error() << "listen(): listen() failed " << errnoWithDescription(); return; } |