summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2018-04-18 18:28:13 -0400
committerAndrew Morrow <acm@mongodb.com>2018-05-05 12:29:55 -0400
commit51dce76324173089098e8c9fd09e46b98b32adc4 (patch)
tree1093a4866d1fc3e7da1cba2fa2ae4f56b536f033 /src
parent30994f3bacb6e814ae015d83693c549a3b924ccc (diff)
downloadmongo-51dce76324173089098e8c9fd09e46b98b32adc4.tar.gz
SERVER-34805 Refactor the network libraries and move messages types to rpc/protocol
Diffstat (limited to 'src')
-rw-r--r--src/mongo/bson/ugly_bson_integration_test.cpp2
-rw-r--r--src/mongo/client/async_client.cpp2
-rw-r--r--src/mongo/client/dbclient.cpp2
-rw-r--r--src/mongo/client/dbclientcursor.h2
-rw-r--r--src/mongo/client/dbclientinterface.h4
-rw-r--r--src/mongo/client/embedded/SConscript20
-rw-r--r--src/mongo/client/embedded/libmongodbcapi.cpp2
-rw-r--r--src/mongo/client/embedded/libmongodbcapi_test.cpp4
-rw-r--r--src/mongo/client/embedded/service_entry_point_embedded.cpp4
-rw-r--r--src/mongo/client/query.h2
-rw-r--r--src/mongo/db/SConscript8
-rw-r--r--src/mongo/db/audit.h2
-rw-r--r--src/mongo/db/auth/SConscript2
-rw-r--r--src/mongo/db/auth/address_restriction_test.cpp2
-rw-r--r--src/mongo/db/auth/sasl_mechanism_registry.cpp2
-rw-r--r--src/mongo/db/auth/user_document_parser_test.cpp2
-rw-r--r--src/mongo/db/clientcursor.h1
-rw-r--r--src/mongo/db/commands.h2
-rw-r--r--src/mongo/db/commands/dbhash.cpp2
-rw-r--r--src/mongo/db/commands/generic_servers.cpp2
-rw-r--r--src/mongo/db/commands/server_status.cpp2
-rw-r--r--src/mongo/db/commands/write_commands/write_commands_common.h1
-rw-r--r--src/mongo/db/concurrency/SConscript4
-rw-r--r--src/mongo/db/curop.cpp2
-rw-r--r--src/mongo/db/curop.h1
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/db.h1
-rw-r--r--src/mongo/db/dbmessage.h2
-rw-r--r--src/mongo/db/introspect.h2
-rw-r--r--src/mongo/db/log_process_details.cpp3
-rw-r--r--src/mongo/db/ops/write_ops.h4
-rw-r--r--src/mongo/db/ops/write_ops_parsers_test_helpers.h2
-rw-r--r--src/mongo/db/pipeline/document_source_coll_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_index_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp1
-rw-r--r--src/mongo/db/query/explain.cpp2
-rw-r--r--src/mongo/db/query/find.h2
-rw-r--r--src/mongo/db/repl/SConscript2
-rw-r--r--src/mongo/db/repl/isself.cpp2
-rw-r--r--src/mongo/db/repl/isself_test.cpp2
-rw-r--r--src/mongo/db/repl/oplog_interface_local.cpp2
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp2
-rw-r--r--src/mongo/db/server_options_helpers.cpp1
-rw-r--r--src/mongo/db/service_entry_point_common.cpp4
-rw-r--r--src/mongo/db/service_entry_point_common.h2
-rw-r--r--src/mongo/db/session.cpp2
-rw-r--r--src/mongo/db/session_test.cpp2
-rw-r--r--src/mongo/db/sessions_collection_sharded.cpp2
-rw-r--r--src/mongo/db/stats/counters.h2
-rw-r--r--src/mongo/db/stats/top.h1
-rw-r--r--src/mongo/dbtests/commandtests.cpp2
-rw-r--r--src/mongo/dbtests/mock_dbclient_conn_test.cpp1
-rw-r--r--src/mongo/dbtests/socktests.cpp2
-rw-r--r--src/mongo/executor/SConscript2
-rw-r--r--src/mongo/executor/async_mock_stream_factory.cpp2
-rw-r--r--src/mongo/executor/network_interface_asio.cpp2
-rw-r--r--src/mongo/executor/network_interface_asio.h2
-rw-r--r--src/mongo/executor/network_interface_asio_test.cpp2
-rw-r--r--src/mongo/executor/network_interface_tl.cpp2
-rw-r--r--src/mongo/executor/remote_command_response.h2
-rw-r--r--src/mongo/idl/idl_test.cpp2
-rw-r--r--src/mongo/rpc/SConscript22
-rw-r--r--src/mongo/rpc/command_reply.cpp2
-rw-r--r--src/mongo/rpc/command_reply_builder.cpp2
-rw-r--r--src/mongo/rpc/command_reply_builder.h2
-rw-r--r--src/mongo/rpc/command_reply_test.cpp2
-rw-r--r--src/mongo/rpc/command_request.cpp2
-rw-r--r--src/mongo/rpc/command_request.h4
-rw-r--r--src/mongo/rpc/command_request_builder.h4
-rw-r--r--src/mongo/rpc/command_request_test.cpp2
-rw-r--r--src/mongo/rpc/factory.cpp2
-rw-r--r--src/mongo/rpc/factory.h2
-rw-r--r--src/mongo/rpc/legacy_reply_builder.h2
-rw-r--r--src/mongo/rpc/legacy_request.h4
-rw-r--r--src/mongo/rpc/legacy_request_builder.cpp2
-rw-r--r--src/mongo/rpc/legacy_request_builder.h4
-rw-r--r--src/mongo/rpc/message.cpp (renamed from src/mongo/util/net/message.cpp)2
-rw-r--r--src/mongo/rpc/message.h (renamed from src/mongo/util/net/message.h)0
-rw-r--r--src/mongo/rpc/metadata.h2
-rw-r--r--src/mongo/rpc/op_msg.cpp (renamed from src/mongo/util/net/op_msg.cpp)2
-rw-r--r--src/mongo/rpc/op_msg.h (renamed from src/mongo/util/net/op_msg.h)2
-rw-r--r--src/mongo/rpc/op_msg_integration_test.cpp (renamed from src/mongo/util/net/op_msg_integration_test.cpp)3
-rw-r--r--src/mongo/rpc/op_msg_rpc_impls.h2
-rw-r--r--src/mongo/rpc/op_msg_test.cpp (renamed from src/mongo/util/net/op_msg_test.cpp)2
-rw-r--r--src/mongo/rpc/protocol.h2
-rw-r--r--src/mongo/rpc/reply_builder_interface.cpp2
-rw-r--r--src/mongo/rpc/unique_message.h2
-rw-r--r--src/mongo/s/SConscript1
-rw-r--r--src/mongo/s/commands/cluster_aggregate.cpp2
-rw-r--r--src/mongo/s/commands/cluster_is_db_grid_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_is_master_cmd.cpp2
-rw-r--r--src/mongo/s/commands/strategy.cpp2
-rw-r--r--src/mongo/s/mongos_options.cpp2
-rw-r--r--src/mongo/s/server.cpp3
-rw-r--r--src/mongo/s/service_entry_point_mongos.cpp2
-rw-r--r--src/mongo/s/sharding_initialization.cpp2
-rw-r--r--src/mongo/s/sharding_uptime_reporter.cpp2
-rw-r--r--src/mongo/s/write_ops/batched_command_request.h2
-rw-r--r--src/mongo/shell/shell_options.cpp2
-rw-r--r--src/mongo/shell/shell_utils_extended.cpp2
-rw-r--r--src/mongo/tools/bridge.cpp2
-rw-r--r--src/mongo/transport/SConscript8
-rw-r--r--src/mongo/transport/asio_utils.h1
-rw-r--r--src/mongo/transport/message_compressor_manager.cpp2
-rw-r--r--src/mongo/transport/message_compressor_manager_test.cpp2
-rw-r--r--src/mongo/transport/service_state_machine.cpp2
-rw-r--r--src/mongo/transport/service_state_machine_test.cpp2
-rw-r--r--src/mongo/transport/session.h2
-rw-r--r--src/mongo/transport/session_asio.h2
-rw-r--r--src/mongo/transport/transport_layer.h1
-rw-r--r--src/mongo/transport/transport_layer_asio.cpp2
-rw-r--r--src/mongo/transport/transport_layer_asio_test.cpp2
-rw-r--r--src/mongo/transport/transport_layer_manager.h1
-rw-r--r--src/mongo/transport/transport_layer_mock.cpp1
-rw-r--r--src/mongo/transport/transport_layer_mock.h1
-rw-r--r--src/mongo/unittest/SConscript74
-rw-r--r--src/mongo/util/net/SConscript54
-rw-r--r--src/mongo/util/net/hostname_canonicalization.cpp2
-rw-r--r--src/mongo/util/net/sock.cpp193
-rw-r--r--src/mongo/util/net/sock.h29
-rw-r--r--src/mongo/util/net/socket_utils.cpp223
-rw-r--r--src/mongo/util/net/socket_utils.h61
-rw-r--r--src/mongo/util/net/ssl_manager_openssl.cpp1
-rw-r--r--src/mongo/util/net/ssl_manager_windows.cpp1
-rw-r--r--src/mongo/util/net/ssl_options.cpp4
-rw-r--r--src/mongo/util/net/ssl_options.h3
126 files changed, 511 insertions, 421 deletions
diff --git a/src/mongo/bson/ugly_bson_integration_test.cpp b/src/mongo/bson/ugly_bson_integration_test.cpp
index df2b584884a..f9479cc0098 100644
--- a/src/mongo/bson/ugly_bson_integration_test.cpp
+++ b/src/mongo/bson/ugly_bson_integration_test.cpp
@@ -33,10 +33,10 @@
#include "mongo/client/connection_string.h"
#include "mongo/executor/network_interface_asio_integration_fixture.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/unittest/integration_test.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/client/async_client.cpp b/src/mongo/client/async_client.cpp
index 44b3d91e521..184f69689a3 100644
--- a/src/mongo/client/async_client.cpp
+++ b/src/mongo/client/async_client.cpp
@@ -47,7 +47,7 @@
#include "mongo/rpc/reply_interface.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index 7ca8bd55540..c93aa177fdd 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -71,8 +71,8 @@
#include "mongo/util/debug_util.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/socket_exception.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/password_digest.h"
diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h
index e8c8e423ea2..0601a3bf6ef 100644
--- a/src/mongo/client/dbclientcursor.h
+++ b/src/mongo/client/dbclientcursor.h
@@ -35,7 +35,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h
index ed79c9cf51c..6048c89f348 100644
--- a/src/mongo/client/dbclientinterface.h
+++ b/src/mongo/client/dbclientinterface.h
@@ -41,7 +41,9 @@
#include "mongo/db/write_concern_options.h"
#include "mongo/logger/log_severity.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/protocol.h"
#include "mongo/rpc/unique_message.h"
#include "mongo/stdx/functional.h"
@@ -49,8 +51,6 @@
#include "mongo/transport/session.h"
#include "mongo/transport/transport_layer.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
diff --git a/src/mongo/client/embedded/SConscript b/src/mongo/client/embedded/SConscript
index 2b9b00045de..deb1c7e5181 100644
--- a/src/mongo/client/embedded/SConscript
+++ b/src/mongo/client/embedded/SConscript
@@ -45,8 +45,9 @@ env.Library(
],
)
-env.Library('repl_coordinator_embedded',
- [
+env.Library(
+ target='repl_coordinator_embedded',
+ source=[
'replication_coordinator_embedded.cpp',
],
LIBDEPS=[
@@ -130,8 +131,8 @@ capi = env.Library(
'libmongodbcapi.cpp',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/util/net/network',
'$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/rpc/protocol',
'$BUILD_DIR/mongo/transport/transport_layer_mock',
'embedded',
],
@@ -162,13 +163,13 @@ capiTest = capiTestEnv.Program(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/commands/shell_protocol',
'$BUILD_DIR/mongo/db/commands/test_commands_enabled',
+ '$BUILD_DIR/mongo/db/server_options_core',
+ '$BUILD_DIR/mongo/rpc/protocol',
'$BUILD_DIR/mongo/unittest/unittest',
'$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser',
'mongo_embedded_capi',
],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/server_options_core',
- ],
INSTALL_ALIAS=[
'mobile-test',
],
@@ -247,12 +248,11 @@ embeddedTransportTest = embeddedTransportTestEnv.Program(
'functions_for_test.cpp',
],
LIBDEPS=[
- 'mongo_embedded_transport',
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/unittest/unittest',
- ],
- LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/server_options_core',
+ '$BUILD_DIR/mongo/unittest/unittest',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser',
+ 'mongo_embedded_transport',
],
INSTALL_ALIAS=[
'mobile-test',
diff --git a/src/mongo/client/embedded/libmongodbcapi.cpp b/src/mongo/client/embedded/libmongodbcapi.cpp
index 358443aa617..3153aa88b65 100644
--- a/src/mongo/client/embedded/libmongodbcapi.cpp
+++ b/src/mongo/client/embedded/libmongodbcapi.cpp
@@ -41,11 +41,11 @@
#include "mongo/db/service_context.h"
#include "mongo/logger/logger.h"
#include "mongo/logger/message_event_utf8_encoder.h"
+#include "mongo/rpc/message.h"
#include "mongo/stdx/unordered_map.h"
#include "mongo/transport/service_entry_point.h"
#include "mongo/transport/transport_layer_mock.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/shared_buffer.h"
diff --git a/src/mongo/client/embedded/libmongodbcapi_test.cpp b/src/mongo/client/embedded/libmongodbcapi_test.cpp
index faa435685be..6b96beb3065 100644
--- a/src/mongo/client/embedded/libmongodbcapi_test.cpp
+++ b/src/mongo/client/embedded/libmongodbcapi_test.cpp
@@ -37,11 +37,11 @@
#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/json.h"
#include "mongo/db/server_options.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/stdx/thread.h"
#include "mongo/unittest/temp_dir.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/options_parser/environment.h"
#include "mongo/util/options_parser/option_section.h"
#include "mongo/util/options_parser/options_parser.h"
diff --git a/src/mongo/client/embedded/service_entry_point_embedded.cpp b/src/mongo/client/embedded/service_entry_point_embedded.cpp
index 702d6bdee44..257235a7332 100644
--- a/src/mongo/client/embedded/service_entry_point_embedded.cpp
+++ b/src/mongo/client/embedded/service_entry_point_embedded.cpp
@@ -63,6 +63,7 @@
#include "mongo/db/stats/top.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata.h"
#include "mongo/rpc/metadata/config_server_metadata.h"
#include "mongo/rpc/metadata/logical_time_metadata.h"
@@ -70,12 +71,11 @@
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/rpc/metadata/sharding_metadata.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/s/grid.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/client/query.h b/src/mongo/client/query.h
index 6c5846e3c32..37af5b0659e 100644
--- a/src/mongo/client/query.h
+++ b/src/mongo/client/query.h
@@ -30,7 +30,7 @@
#include "mongo/bson/json.h"
#include "mongo/client/read_preference.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index a77d3d7de2e..3821a34d592 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -167,7 +167,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
]
)
@@ -389,9 +389,9 @@ env.Clone().InjectModule("enterprise").Library(
'$BUILD_DIR/mongo/util/cmdline_utils/cmdline_utils',
'$BUILD_DIR/mongo/util/fail_point',
'$BUILD_DIR/mongo/transport/message_compressor',
- # The dependency on network is a temporary crutch that should go away once the
+ # The dependency on net/ssl_manager is a temporary crutch that should go away once the
# networking library has separate options
- '$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
'$BUILD_DIR/mongo/util/options_parser/options_parser',
'server_options_core',
'server_parameters',
@@ -493,7 +493,7 @@ env.Library(
'$BUILD_DIR/mongo/util/clock_sources',
'$BUILD_DIR/mongo/util/concurrency/spin_lock',
'$BUILD_DIR/mongo/util/fail_point',
- '$BUILD_DIR/mongo/util/net/host',
+ '$BUILD_DIR/mongo/util/net/network',
'$BUILD_DIR/mongo/util/periodic_runner',
],
)
diff --git a/src/mongo/db/audit.h b/src/mongo/db/audit.h
index be20849545a..10cbd651944 100644
--- a/src/mongo/db/audit.h
+++ b/src/mongo/db/audit.h
@@ -36,7 +36,7 @@
#include "mongo/base/error_codes.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/auth/user.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
diff --git a/src/mongo/db/auth/SConscript b/src/mongo/db/auth/SConscript
index ccc15db37bb..ee7829fb043 100644
--- a/src/mongo/db/auth/SConscript
+++ b/src/mongo/db/auth/SConscript
@@ -85,7 +85,7 @@ env.Library(
'$BUILD_DIR/mongo/db/update/update_driver',
'$BUILD_DIR/mongo/util/md5',
'$BUILD_DIR/mongo/util/icu',
- '$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
],
)
diff --git a/src/mongo/db/auth/address_restriction_test.cpp b/src/mongo/db/auth/address_restriction_test.cpp
index 380e35d8d74..136dc8da5a4 100644
--- a/src/mongo/db/auth/address_restriction_test.cpp
+++ b/src/mongo/db/auth/address_restriction_test.cpp
@@ -30,8 +30,8 @@
#include "mongo/db/auth/address_restriction.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/sockaddr.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
namespace {
diff --git a/src/mongo/db/auth/sasl_mechanism_registry.cpp b/src/mongo/db/auth/sasl_mechanism_registry.cpp
index 4daebdb5542..3426ca97b80 100644
--- a/src/mongo/db/auth/sasl_mechanism_registry.cpp
+++ b/src/mongo/db/auth/sasl_mechanism_registry.cpp
@@ -36,7 +36,7 @@
#include "mongo/db/auth/user.h"
#include "mongo/util/icu.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/sequence_util.h"
diff --git a/src/mongo/db/auth/user_document_parser_test.cpp b/src/mongo/db/auth/user_document_parser_test.cpp
index 94f9f9d70b0..77e795571a8 100644
--- a/src/mongo/db/auth/user_document_parser_test.cpp
+++ b/src/mongo/db/auth/user_document_parser_test.cpp
@@ -40,7 +40,7 @@
#include "mongo/db/auth/user_document_parser.h"
#include "mongo/db/jsobj.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#define ASSERT_NULL(EXPR) ASSERT_FALSE(EXPR)
#define ASSERT_NON_NULL(EXPR) ASSERT_TRUE(EXPR)
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index 42e7c20f069..a07e54e1524 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -39,7 +39,6 @@
#include "mongo/db/record_id.h"
#include "mongo/db/repl/read_concern_level.h"
#include "mongo/stdx/functional.h"
-#include "mongo/util/net/message.h"
namespace mongo {
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index dbdaf8153a4..b0573ab3a97 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -43,9 +43,9 @@
#include "mongo/db/query/explain.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/write_concern.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/stdx/functional.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/string_map.h"
namespace mongo {
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp
index e1db0f7fd08..c7aa1c64e14 100644
--- a/src/mongo/db/commands/dbhash.cpp
+++ b/src/mongo/db/commands/dbhash.cpp
@@ -47,7 +47,7 @@
#include "mongo/stdx/mutex.h"
#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/timer.h"
namespace mongo {
diff --git a/src/mongo/db/commands/generic_servers.cpp b/src/mongo/db/commands/generic_servers.cpp
index 152b9437966..c3612a49a26 100644
--- a/src/mongo/db/commands/generic_servers.cpp
+++ b/src/mongo/db/commands/generic_servers.cpp
@@ -41,7 +41,7 @@
#include "mongo/util/fail_point.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/ntservice.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/ramlog.h"
diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp
index 041c4e31ab6..65c653fc089 100644
--- a/src/mongo/db/commands/server_status.cpp
+++ b/src/mongo/db/commands/server_status.cpp
@@ -51,7 +51,7 @@
#include "mongo/transport/service_entry_point.h"
#include "mongo/util/log.h"
#include "mongo/util/net/hostname_canonicalization.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/ramlog.h"
diff --git a/src/mongo/db/commands/write_commands/write_commands_common.h b/src/mongo/db/commands/write_commands/write_commands_common.h
index 8f9110743cc..871744d2c69 100644
--- a/src/mongo/db/commands/write_commands/write_commands_common.h
+++ b/src/mongo/db/commands/write_commands/write_commands_common.h
@@ -32,7 +32,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/ops/write_ops_gen.h"
-#include "mongo/util/net/op_msg.h"
/**
* Contains common functionality shared between the batch write commands in mongos and mongod.
diff --git a/src/mongo/db/concurrency/SConscript b/src/mongo/db/concurrency/SConscript
index 41c5abace77..947096a1eab 100644
--- a/src/mongo/db/concurrency/SConscript
+++ b/src/mongo/db/concurrency/SConscript
@@ -42,12 +42,10 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/util/background_job',
-
- # Temporary crutch since the ssl cleanup is hard coded in background.cpp
'$BUILD_DIR/mongo/db/server_parameters',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/concurrency/spin_lock',
- '$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/concurrency/ticketholder',
'$BUILD_DIR/third_party/shim_boost',
],
)
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 7e49341609c..bca7c71a7ff 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -46,7 +46,7 @@
#include "mongo/rpc/metadata/client_metadata.h"
#include "mongo/rpc/metadata/client_metadata_ismaster.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/stringutils.h"
namespace mongo {
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index d4780730635..06bc4934842 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -37,7 +37,6 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/server_options.h"
#include "mongo/platform/atomic_word.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/progress_meter.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index f9496fe49cf..1742e7b5197 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -158,7 +158,7 @@
#include "mongo/util/fail_point_service.h"
#include "mongo/util/fast_clock_source_factory.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/ntservice.h"
#include "mongo/util/options_parser/startup_options.h"
diff --git a/src/mongo/db/db.h b/src/mongo/db/db.h
index e94bb34ccb2..b269cc03dbe 100644
--- a/src/mongo/db/db.h
+++ b/src/mongo/db/db.h
@@ -34,7 +34,6 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
-#include "mongo/util/net/message.h"
namespace mongo {
diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h
index a7228cbc4be..e545130e7ed 100644
--- a/src/mongo/db/dbmessage.h
+++ b/src/mongo/db/dbmessage.h
@@ -35,7 +35,7 @@
#include "mongo/client/constants.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/server_options.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/db/introspect.h b/src/mongo/db/introspect.h
index bf2214cde34..c880b7c2577 100644
--- a/src/mongo/db/introspect.h
+++ b/src/mongo/db/introspect.h
@@ -29,7 +29,7 @@
#pragma once
#include "mongo/base/status.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/db/log_process_details.cpp b/src/mongo/db/log_process_details.cpp
index d12b0ebce29..3719699aaa5 100644
--- a/src/mongo/db/log_process_details.cpp
+++ b/src/mongo/db/log_process_details.cpp
@@ -39,8 +39,7 @@
#include "mongo/db/server_options.h"
#include "mongo/db/server_options_helpers.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
-#include "mongo/util/net/ssl_manager.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/db/ops/write_ops.h b/src/mongo/db/ops/write_ops.h
index 4f97d466dff..c3201f7f56f 100644
--- a/src/mongo/db/ops/write_ops.h
+++ b/src/mongo/db/ops/write_ops.h
@@ -29,8 +29,8 @@
#pragma once
#include "mongo/db/ops/write_ops_gen.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
diff --git a/src/mongo/db/ops/write_ops_parsers_test_helpers.h b/src/mongo/db/ops/write_ops_parsers_test_helpers.h
index 4debd525945..2c35eb5abfd 100644
--- a/src/mongo/db/ops/write_ops_parsers_test_helpers.h
+++ b/src/mongo/db/ops/write_ops_parsers_test_helpers.h
@@ -29,7 +29,7 @@
#pragma once
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
/**
diff --git a/src/mongo/db/pipeline/document_source_coll_stats.cpp b/src/mongo/db/pipeline/document_source_coll_stats.cpp
index 7d05a806e98..9aec2ba3475 100644
--- a/src/mongo/db/pipeline/document_source_coll_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_coll_stats.cpp
@@ -33,7 +33,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/db/pipeline/lite_parsed_document_source.h"
#include "mongo/db/stats/top.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/time_support.h"
using boost::intrusive_ptr;
diff --git a/src/mongo/db/pipeline/document_source_index_stats.cpp b/src/mongo/db/pipeline/document_source_index_stats.cpp
index dfb69786d18..a87c763f30f 100644
--- a/src/mongo/db/pipeline/document_source_index_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_index_stats.cpp
@@ -32,7 +32,7 @@
#include "mongo/db/pipeline/lite_parsed_document_source.h"
#include "mongo/db/server_options.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 52b7860c511..7b5cd468130 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -87,7 +87,6 @@
#include "mongo/s/grid.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp
index ae985487ffb..daefe9c3aea 100644
--- a/src/mongo/db/query/explain.cpp
+++ b/src/mongo/db/query/explain.cpp
@@ -52,7 +52,7 @@
#include "mongo/db/server_options.h"
#include "mongo/db/server_parameters.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/version.h"
namespace {
diff --git a/src/mongo/db/query/find.h b/src/mongo/db/query/find.h
index 42a0da92380..ed049ae7e8d 100644
--- a/src/mongo/db/query/find.h
+++ b/src/mongo/db/query/find.h
@@ -34,7 +34,7 @@
#include "mongo/db/dbmessage.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/query/canonical_query.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 46c69c67ee4..8599eb1db81 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -477,7 +477,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/util/net/host',
+ '$BUILD_DIR/mongo/util/net/network',
],
)
diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp
index fac8572433f..2d32cfc0b8e 100644
--- a/src/mongo/db/repl/isself.cpp
+++ b/src/mongo/db/repl/isself.cpp
@@ -46,7 +46,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/service_context.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/scopeguard.h"
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) || \
diff --git a/src/mongo/db/repl/isself_test.cpp b/src/mongo/db/repl/isself_test.cpp
index 254f25c5ae3..55a13c675d7 100644
--- a/src/mongo/db/repl/isself_test.cpp
+++ b/src/mongo/db/repl/isself_test.cpp
@@ -33,7 +33,7 @@
#include "mongo/db/service_context.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/net/hostandport.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/db/repl/oplog_interface_local.cpp b/src/mongo/db/repl/oplog_interface_local.cpp
index d140063b6b1..a3df8132dd4 100644
--- a/src/mongo/db/repl/oplog_interface_local.cpp
+++ b/src/mongo/db/repl/oplog_interface_local.cpp
@@ -35,7 +35,7 @@
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 288dc66c389..1c16974ff06 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -66,7 +66,7 @@
#include "mongo/transport/transport_layer.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp
index 96275fb5083..578bcd6855c 100644
--- a/src/mongo/db/server_options_helpers.cpp
+++ b/src/mongo/db/server_options_helpers.cpp
@@ -55,6 +55,7 @@
#include "mongo/util/map_util.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 22d4e608a60..37e41a77ab4 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -74,6 +74,7 @@
#include "mongo/db/stats/top.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata.h"
#include "mongo/rpc/metadata/config_server_metadata.h"
#include "mongo/rpc/metadata/logical_time_metadata.h"
@@ -81,14 +82,13 @@
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/rpc/metadata/sharding_metadata.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/s/cannot_implicitly_create_collection_info.h"
#include "mongo/s/grid.h"
#include "mongo/s/stale_exception.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/db/service_entry_point_common.h b/src/mongo/db/service_entry_point_common.h
index cbf9905b339..ac524dbcdc6 100644
--- a/src/mongo/db/service_entry_point_common.h
+++ b/src/mongo/db/service_entry_point_common.h
@@ -34,8 +34,8 @@
#include "mongo/db/commands.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/operation_context.h"
+#include "mongo/rpc/message.h"
#include "mongo/util/fail_point_service.h"
-#include "mongo/util/net/message.h"
namespace mongo {
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 5a8c1cee67c..74242fc1255 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -56,7 +56,7 @@
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp
index f992721decc..fc07d137576 100644
--- a/src/mongo/db/session_test.cpp
+++ b/src/mongo/db/session_test.cpp
@@ -43,7 +43,7 @@
#include "mongo/stdx/memory.h"
#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
namespace {
diff --git a/src/mongo/db/sessions_collection_sharded.cpp b/src/mongo/db/sessions_collection_sharded.cpp
index 65337bebb05..a82f8df1332 100644
--- a/src/mongo/db/sessions_collection_sharded.cpp
+++ b/src/mongo/db/sessions_collection_sharded.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/query/query_request.h"
#include "mongo/db/sessions_collection_rs.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/grid.h"
#include "mongo/s/query/cluster_find.h"
@@ -43,7 +44,6 @@
#include "mongo/s/write_ops/batched_command_request.h"
#include "mongo/s/write_ops/batched_command_response.h"
#include "mongo/s/write_ops/cluster_write.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
diff --git a/src/mongo/db/stats/counters.h b/src/mongo/db/stats/counters.h
index 1522da5b1aa..e5df96441b9 100644
--- a/src/mongo/db/stats/counters.h
+++ b/src/mongo/db/stats/counters.h
@@ -32,8 +32,8 @@
#include "mongo/db/jsobj.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/platform/basic.h"
+#include "mongo/rpc/message.h"
#include "mongo/util/concurrency/spin_lock.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/with_alignment.h"
diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h
index 463482199fe..ccd4ac5e13f 100644
--- a/src/mongo/db/stats/top.h
+++ b/src/mongo/db/stats/top.h
@@ -35,7 +35,6 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/stats/operation_latency_histogram.h"
#include "mongo/util/concurrency/mutex.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/string_map.h"
namespace mongo {
diff --git a/src/mongo/dbtests/commandtests.cpp b/src/mongo/dbtests/commandtests.cpp
index be9cd1ecf60..2d234918056 100644
--- a/src/mongo/dbtests/commandtests.cpp
+++ b/src/mongo/dbtests/commandtests.cpp
@@ -36,7 +36,7 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/operation_context.h"
#include "mongo/dbtests/dbtests.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/op_msg.h"
using namespace mongo;
diff --git a/src/mongo/dbtests/mock_dbclient_conn_test.cpp b/src/mongo/dbtests/mock_dbclient_conn_test.cpp
index 9ae092e1518..5c02d561541 100644
--- a/src/mongo/dbtests/mock_dbclient_conn_test.cpp
+++ b/src/mongo/dbtests/mock_dbclient_conn_test.cpp
@@ -35,7 +35,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/dbtests/mock/mock_dbclient_connection.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/socket_exception.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/dbtests/socktests.cpp b/src/mongo/dbtests/socktests.cpp
index e0a9fbb2fed..1b68a58f259 100644
--- a/src/mongo/dbtests/socktests.cpp
+++ b/src/mongo/dbtests/socktests.cpp
@@ -34,7 +34,7 @@
#include "mongo/db/repl/isself.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/util/net/hostandport.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace SockTests {
diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript
index 6c13b1c460b..4b75702604e 100644
--- a/src/mongo/executor/SConscript
+++ b/src/mongo/executor/SConscript
@@ -218,7 +218,7 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base/system_error',
'$BUILD_DIR/mongo/client/authentication',
- '$BUILD_DIR/mongo/util/net/ssl_stream',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
'$BUILD_DIR/third_party/shim_asio',
'task_executor_interface',
]
diff --git a/src/mongo/executor/async_mock_stream_factory.cpp b/src/mongo/executor/async_mock_stream_factory.cpp
index 2951f977bcd..0d57e80ac5b 100644
--- a/src/mongo/executor/async_mock_stream_factory.cpp
+++ b/src/mongo/executor/async_mock_stream_factory.cpp
@@ -40,10 +40,10 @@
#include "mongo/rpc/command_reply_builder.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/legacy_reply_builder.h"
+#include "mongo/rpc/message.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace executor {
diff --git a/src/mongo/executor/network_interface_asio.cpp b/src/mongo/executor/network_interface_asio.cpp
index 8d74d56656f..7eabcfbb71e 100644
--- a/src/mongo/executor/network_interface_asio.cpp
+++ b/src/mongo/executor/network_interface_asio.cpp
@@ -49,7 +49,7 @@
#include "mongo/util/concurrency/idle_thread_block.h"
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/table_formatter.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/executor/network_interface_asio.h b/src/mongo/executor/network_interface_asio.h
index 8f57e3d08b8..3a423e8b779 100644
--- a/src/mongo/executor/network_interface_asio.h
+++ b/src/mongo/executor/network_interface_asio.h
@@ -48,6 +48,7 @@
#include "mongo/executor/remote_command_request.h"
#include "mongo/executor/remote_command_response.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata/metadata_hook.h"
#include "mongo/rpc/protocol.h"
#include "mongo/stdx/condition_variable.h"
@@ -57,7 +58,6 @@
#include "mongo/stdx/unordered_map.h"
#include "mongo/stdx/unordered_set.h"
#include "mongo/transport/message_compressor_manager.h"
-#include "mongo/util/net/message.h"
namespace mongo {
diff --git a/src/mongo/executor/network_interface_asio_test.cpp b/src/mongo/executor/network_interface_asio_test.cpp
index 4ba979d8e28..a5ca74a89c7 100644
--- a/src/mongo/executor/network_interface_asio_test.cpp
+++ b/src/mongo/executor/network_interface_asio_test.cpp
@@ -42,11 +42,11 @@
#include "mongo/executor/test_network_connection_hook.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/legacy_reply_builder.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata/egress_metadata_hook_list.h"
#include "mongo/stdx/memory.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 15947af2c0b..17ec411eec5 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -37,7 +37,7 @@
#include "mongo/transport/transport_layer_manager.h"
#include "mongo/util/concurrency/idle_thread_block.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
namespace executor {
diff --git a/src/mongo/executor/remote_command_response.h b/src/mongo/executor/remote_command_response.h
index a263157f614..0dd51f68ba8 100644
--- a/src/mongo/executor/remote_command_response.h
+++ b/src/mongo/executor/remote_command_response.h
@@ -35,7 +35,7 @@
#include "mongo/base/status.h"
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp
index 935c70f17dc..8818132c65e 100644
--- a/src/mongo/idl/idl_test.cpp
+++ b/src/mongo/idl/idl_test.cpp
@@ -31,8 +31,8 @@
#include "mongo/bson/bsonmisc.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/idl/unittest_gen.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/op_msg.h"
using namespace mongo::idl::test;
using namespace mongo::idl::import;
diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript
index c3b364020a7..637c62ffaa7 100644
--- a/src/mongo/rpc/SConscript
+++ b/src/mongo/rpc/SConscript
@@ -24,14 +24,19 @@ env.Library(
'protocol',
],
source=[
+ 'message.cpp',
+ 'op_msg.cpp',
'protocol.cpp',
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/bson/util/bson_extract',
- '$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/wire_version',
],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/bson/util/bson_extract',
+ '$BUILD_DIR/mongo/db/bson/dotted_path_support',
+ '$BUILD_DIR/mongo/db/server_options_core',
+ ],
)
env.Library(
@@ -180,6 +185,7 @@ env.CppUnitTest(
'get_status_from_command_result_test.cpp',
'legacy_request_test.cpp',
'object_check_test.cpp',
+ 'op_msg_test.cpp',
'protocol_test.cpp',
'reply_builder_test.cpp',
],
@@ -238,3 +244,15 @@ env.CppUnitTest(
'client_metadata',
]
)
+
+env.CppIntegrationTest(
+ target='op_msg_integration_test',
+ source=[
+ 'op_msg_integration_test.cpp',
+ ],
+ LIBDEPS=[
+ 'protocol',
+ '$BUILD_DIR/mongo/client/clientdriver',
+ '$BUILD_DIR/mongo/util/version_impl',
+ ],
+)
diff --git a/src/mongo/rpc/command_reply.cpp b/src/mongo/rpc/command_reply.cpp
index 884a63fae61..79de0cc5506 100644
--- a/src/mongo/rpc/command_reply.cpp
+++ b/src/mongo/rpc/command_reply.cpp
@@ -36,8 +36,8 @@
#include "mongo/base/data_range_cursor.h"
#include "mongo/base/data_type_validated.h"
#include "mongo/bson/simple_bsonobj_comparator.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/object_check.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_reply_builder.cpp b/src/mongo/rpc/command_reply_builder.cpp
index 001522163ce..534ad779f86 100644
--- a/src/mongo/rpc/command_reply_builder.cpp
+++ b/src/mongo/rpc/command_reply_builder.cpp
@@ -32,10 +32,10 @@
#include <utility>
+#include "mongo/rpc/message.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_reply_builder.h b/src/mongo/rpc/command_reply_builder.h
index b990ca3d8fa..cce27f90b01 100644
--- a/src/mongo/rpc/command_reply_builder.h
+++ b/src/mongo/rpc/command_reply_builder.h
@@ -32,9 +32,9 @@
#include "mongo/base/status.h"
#include "mongo/db/jsobj.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/protocol.h"
#include "mongo/rpc/reply_builder_interface.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_reply_test.cpp b/src/mongo/rpc/command_reply_test.cpp
index 77bf5ba59a1..e207c497b2b 100644
--- a/src/mongo/rpc/command_reply_test.cpp
+++ b/src/mongo/rpc/command_reply_test.cpp
@@ -37,9 +37,9 @@
#include "mongo/base/data_view.h"
#include "mongo/db/jsobj.h"
#include "mongo/rpc/command_reply.h"
+#include "mongo/rpc/message.h"
#include "mongo/stdx/memory.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/message.h"
namespace {
diff --git a/src/mongo/rpc/command_request.cpp b/src/mongo/rpc/command_request.cpp
index 98e85f02f5f..bce2323bfe5 100644
--- a/src/mongo/rpc/command_request.cpp
+++ b/src/mongo/rpc/command_request.cpp
@@ -40,10 +40,10 @@
#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/client/read_preference.h"
#include "mongo/db/jsobj.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/object_check.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_request.h b/src/mongo/rpc/command_request.h
index 07cefccdb0e..d2163185422 100644
--- a/src/mongo/rpc/command_request.h
+++ b/src/mongo/rpc/command_request.h
@@ -29,8 +29,8 @@
#pragma once
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_request_builder.h b/src/mongo/rpc/command_request_builder.h
index 0e3ae41fbca..e890dd978b1 100644
--- a/src/mongo/rpc/command_request_builder.h
+++ b/src/mongo/rpc/command_request_builder.h
@@ -28,8 +28,8 @@
#pragma once
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/command_request_test.cpp b/src/mongo/rpc/command_request_test.cpp
index aad6dd1d3ff..5902766c2be 100644
--- a/src/mongo/rpc/command_request_test.cpp
+++ b/src/mongo/rpc/command_request_test.cpp
@@ -35,9 +35,9 @@
#include "mongo/db/jsobj.h"
#include "mongo/rpc/command_request.h"
#include "mongo/rpc/command_request_builder.h"
+#include "mongo/rpc/message.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/net/message.h"
namespace {
diff --git a/src/mongo/rpc/factory.cpp b/src/mongo/rpc/factory.cpp
index 6ef513c0284..94bd71f6c39 100644
--- a/src/mongo/rpc/factory.cpp
+++ b/src/mongo/rpc/factory.cpp
@@ -38,12 +38,12 @@
#include "mongo/rpc/legacy_reply_builder.h"
#include "mongo/rpc/legacy_request.h"
#include "mongo/rpc/legacy_request_builder.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/op_msg_rpc_impls.h"
#include "mongo/rpc/protocol.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/factory.h b/src/mongo/rpc/factory.h
index fb3f7c0b853..724809ed771 100644
--- a/src/mongo/rpc/factory.h
+++ b/src/mongo/rpc/factory.h
@@ -28,8 +28,8 @@
#pragma once
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/protocol.h"
-#include "mongo/util/net/op_msg.h"
#include <memory>
diff --git a/src/mongo/rpc/legacy_reply_builder.h b/src/mongo/rpc/legacy_reply_builder.h
index fba41aabdfe..22f40092df6 100644
--- a/src/mongo/rpc/legacy_reply_builder.h
+++ b/src/mongo/rpc/legacy_reply_builder.h
@@ -32,9 +32,9 @@
#include "mongo/base/status.h"
#include "mongo/bson/util/builder.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/protocol.h"
#include "mongo/rpc/reply_builder_interface.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/legacy_request.h b/src/mongo/rpc/legacy_request.h
index 81c0bb9d94c..a5435ae09be 100644
--- a/src/mongo/rpc/legacy_request.h
+++ b/src/mongo/rpc/legacy_request.h
@@ -28,8 +28,8 @@
#pragma once
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/legacy_request_builder.cpp b/src/mongo/rpc/legacy_request_builder.cpp
index 80ace2b994e..d7978ef65a7 100644
--- a/src/mongo/rpc/legacy_request_builder.cpp
+++ b/src/mongo/rpc/legacy_request_builder.cpp
@@ -36,10 +36,10 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/client/read_preference.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/metadata.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/legacy_request_builder.h b/src/mongo/rpc/legacy_request_builder.h
index 31c8c9b0f77..37a4057d6c2 100644
--- a/src/mongo/rpc/legacy_request_builder.h
+++ b/src/mongo/rpc/legacy_request_builder.h
@@ -28,8 +28,8 @@
#pragma once
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/message.h"
+#include "mongo/rpc/op_msg.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/util/net/message.cpp b/src/mongo/rpc/message.cpp
index 5650c0e3222..f5a7822bd6b 100644
--- a/src/mongo/util/net/message.cpp
+++ b/src/mongo/rpc/message.cpp
@@ -28,7 +28,7 @@
#include "mongo/platform/basic.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
#include "mongo/platform/atomic_word.h"
diff --git a/src/mongo/util/net/message.h b/src/mongo/rpc/message.h
index a2fe2ec8c9d..a2fe2ec8c9d 100644
--- a/src/mongo/util/net/message.h
+++ b/src/mongo/rpc/message.h
diff --git a/src/mongo/rpc/metadata.h b/src/mongo/rpc/metadata.h
index 461927f32a7..b2b3ff13a3e 100644
--- a/src/mongo/rpc/metadata.h
+++ b/src/mongo/rpc/metadata.h
@@ -31,8 +31,8 @@
#include <tuple>
#include "mongo/base/status_with.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/stdx/functional.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
class BSONObj;
diff --git a/src/mongo/util/net/op_msg.cpp b/src/mongo/rpc/op_msg.cpp
index f2ab7167826..f886027e192 100644
--- a/src/mongo/util/net/op_msg.cpp
+++ b/src/mongo/rpc/op_msg.cpp
@@ -30,7 +30,7 @@
#include "mongo/platform/basic.h"
-#include "mongo/util/net/op_msg.h"
+#include "mongo/rpc/op_msg.h"
#include <bitset>
#include <set>
diff --git a/src/mongo/util/net/op_msg.h b/src/mongo/rpc/op_msg.h
index 3e933aa9b31..ed7f1993d86 100644
--- a/src/mongo/util/net/op_msg.h
+++ b/src/mongo/rpc/op_msg.h
@@ -34,7 +34,7 @@
#include "mongo/base/string_data.h"
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
diff --git a/src/mongo/util/net/op_msg_integration_test.cpp b/src/mongo/rpc/op_msg_integration_test.cpp
index a7f730ed7e8..6dd9fec7f2f 100644
--- a/src/mongo/util/net/op_msg_integration_test.cpp
+++ b/src/mongo/rpc/op_msg_integration_test.cpp
@@ -30,12 +30,11 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/unittest/integration_test.h"
#include "mongo/unittest/unittest.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/scopeguard.h"
-
namespace mongo {
TEST(OpMsg, UnknownRequiredFlagClosesConnection) {
diff --git a/src/mongo/rpc/op_msg_rpc_impls.h b/src/mongo/rpc/op_msg_rpc_impls.h
index 67149810d04..4725456630f 100644
--- a/src/mongo/rpc/op_msg_rpc_impls.h
+++ b/src/mongo/rpc/op_msg_rpc_impls.h
@@ -28,9 +28,9 @@
#pragma once
+#include "mongo/rpc/op_msg.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/rpc/reply_interface.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/util/net/op_msg_test.cpp b/src/mongo/rpc/op_msg_test.cpp
index d884e13fc6f..29df95c9136 100644
--- a/src/mongo/util/net/op_msg_test.cpp
+++ b/src/mongo/rpc/op_msg_test.cpp
@@ -36,10 +36,10 @@
#include "mongo/bson/json.h"
#include "mongo/bson/util/builder.h"
#include "mongo/db/jsobj.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
namespace {
diff --git a/src/mongo/rpc/protocol.h b/src/mongo/rpc/protocol.h
index c7500761e98..10e770271d3 100644
--- a/src/mongo/rpc/protocol.h
+++ b/src/mongo/rpc/protocol.h
@@ -34,7 +34,7 @@
#include "mongo/base/status_with.h"
#include "mongo/db/wire_version.h"
-#include "mongo/util/net/message.h"
+#include "mongo/rpc/message.h"
namespace mongo {
class BSONObj;
diff --git a/src/mongo/rpc/reply_builder_interface.cpp b/src/mongo/rpc/reply_builder_interface.cpp
index 9c5b2998e2f..461e3edc6a3 100644
--- a/src/mongo/rpc/reply_builder_interface.cpp
+++ b/src/mongo/rpc/reply_builder_interface.cpp
@@ -34,8 +34,6 @@
#include "mongo/base/status_with.h"
#include "mongo/db/jsobj.h"
-#include "mongo/util/net/message.h"
-
namespace mongo {
namespace rpc {
diff --git a/src/mongo/rpc/unique_message.h b/src/mongo/rpc/unique_message.h
index dd23729445a..b98d806dc0a 100644
--- a/src/mongo/rpc/unique_message.h
+++ b/src/mongo/rpc/unique_message.h
@@ -32,8 +32,8 @@
#include <utility>
#include "mongo/base/disallow_copying.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/reply_interface.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace rpc {
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index 5a9854df0ac..5f0f3d9e934 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -62,6 +62,7 @@ env.Library(
'$BUILD_DIR/mongo/db/query/query_planner',
'$BUILD_DIR/mongo/db/storage/key_string',
'$BUILD_DIR/mongo/db/update/update_common',
+ '$BUILD_DIR/mongo/util/concurrency/ticketholder',
'common_s',
],
)
diff --git a/src/mongo/s/commands/cluster_aggregate.cpp b/src/mongo/s/commands/cluster_aggregate.cpp
index 80c45f7c5b8..a5cc67049b7 100644
--- a/src/mongo/s/commands/cluster_aggregate.cpp
+++ b/src/mongo/s/commands/cluster_aggregate.cpp
@@ -70,7 +70,7 @@
#include "mongo/s/stale_exception.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
diff --git a/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp b/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp
index bed736c152e..e876744d1d2 100644
--- a/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp
@@ -29,7 +29,7 @@
#include "mongo/platform/basic.h"
#include "mongo/db/commands.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
namespace {
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp
index 2b45078ab2d..d94f6abb182 100644
--- a/src/mongo/s/commands/cluster_is_master_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -40,7 +40,7 @@
#include "mongo/rpc/metadata/client_metadata_ismaster.h"
#include "mongo/transport/message_compressor_manager.h"
#include "mongo/util/map_util.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index c0edc37f1f3..612b5b61191 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -61,6 +61,7 @@
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/rpc/metadata/logical_time_metadata.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/s/cannot_implicitly_create_collection_info.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/client/parallel.h"
@@ -75,7 +76,6 @@
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp
index fea657c5c02..5b1a5230037 100644
--- a/src/mongo/s/mongos_options.cpp
+++ b/src/mongo/s/mongos_options.cpp
@@ -45,7 +45,7 @@
#include "mongo/s/version_mongos.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index 627cdf44a3c..8e0db8b8e21 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -100,9 +100,8 @@
#include "mongo/util/exit.h"
#include "mongo/util/fast_clock_source_factory.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/socket_exception.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/ntservice.h"
#include "mongo/util/options_parser/startup_options.h"
diff --git a/src/mongo/s/service_entry_point_mongos.cpp b/src/mongo/s/service_entry_point_mongos.cpp
index 7b2c10fbc9b..366c05d3f60 100644
--- a/src/mongo/s/service_entry_point_mongos.cpp
+++ b/src/mongo/s/service_entry_point_mongos.cpp
@@ -39,11 +39,11 @@
#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
+#include "mongo/rpc/message.h"
#include "mongo/s/client/shard_connection.h"
#include "mongo/s/cluster_last_error_info.h"
#include "mongo/s/commands/strategy.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp
index 7b595826256..c090379b83b 100644
--- a/src/mongo/s/sharding_initialization.cpp
+++ b/src/mongo/s/sharding_initialization.cpp
@@ -70,7 +70,7 @@
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
namespace mongo {
diff --git a/src/mongo/s/sharding_uptime_reporter.cpp b/src/mongo/s/sharding_uptime_reporter.cpp
index 8b343274832..e0844f4a6cd 100644
--- a/src/mongo/s/sharding_uptime_reporter.cpp
+++ b/src/mongo/s/sharding_uptime_reporter.cpp
@@ -42,7 +42,7 @@
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/hostname_canonicalization.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h
index 4ec8f59e3dc..29812e1b9d0 100644
--- a/src/mongo/s/write_ops/batched_command_request.h
+++ b/src/mongo/s/write_ops/batched_command_request.h
@@ -31,9 +31,9 @@
#include <boost/optional.hpp>
#include "mongo/db/ops/write_ops.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/s/chunk_version.h"
#include "mongo/stdx/memory.h"
-#include "mongo/util/net/op_msg.h"
namespace mongo {
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 4f071c04b09..355ff059f01 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -47,7 +47,7 @@
#include "mongo/transport/message_compressor_registry.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp
index 5f95cc2d3ed..583e5c70ac9 100644
--- a/src/mongo/shell/shell_utils_extended.cpp
+++ b/src/mongo/shell/shell_utils_extended.cpp
@@ -42,7 +42,7 @@
#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp
index 876f178fd40..9f85649b9c2 100644
--- a/src/mongo/tools/bridge.cpp
+++ b/src/mongo/tools/bridge.cpp
@@ -44,6 +44,7 @@
#include "mongo/platform/random.h"
#include "mongo/rpc/command_request.h"
#include "mongo/rpc/factory.h"
+#include "mongo/rpc/message.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
@@ -58,7 +59,6 @@
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/quick_exit.h"
#include "mongo/util/signal_handlers.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/transport/SConscript b/src/mongo/transport/SConscript
index 4c56abf9262..77942810b7d 100644
--- a/src/mongo/transport/SConscript
+++ b/src/mongo/transport/SConscript
@@ -25,7 +25,7 @@ env.Library(
'transport_layer_common',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/util/net/host',
+ '$BUILD_DIR/mongo/util/net/network',
],
)
@@ -60,8 +60,7 @@ tlEnv.Library(
'$BUILD_DIR/mongo/db/stats/counters',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/util/net/host',
- '$BUILD_DIR/mongo/util/net/ssl_stream',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
'$BUILD_DIR/third_party/shim_asio',
],
)
@@ -88,6 +87,8 @@ tlEnv.CppUnitTest(
'transport_layer',
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/service_context_noop_init',
+ '$BUILD_DIR/mongo/rpc/protocol',
+ '$BUILD_DIR/mongo/util/net/ssl_manager',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/third_party/shim_asio',
@@ -168,6 +169,7 @@ env.Library(
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/stats/counters',
+ '$BUILD_DIR/mongo/rpc/protocol',
'$BUILD_DIR/mongo/util/processinfo',
'transport_layer_common',
],
diff --git a/src/mongo/transport/asio_utils.h b/src/mongo/transport/asio_utils.h
index 3d38694266f..a4fac9aefda 100644
--- a/src/mongo/transport/asio_utils.h
+++ b/src/mongo/transport/asio_utils.h
@@ -35,6 +35,7 @@
#include "mongo/util/future.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/net/sockaddr.h"
+#include "mongo/util/net/ssl_manager.h"
#ifndef _WIN32
#include <sys/poll.h>
diff --git a/src/mongo/transport/message_compressor_manager.cpp b/src/mongo/transport/message_compressor_manager.cpp
index 5e911ba0a8d..86e71e644f4 100644
--- a/src/mongo/transport/message_compressor_manager.cpp
+++ b/src/mongo/transport/message_compressor_manager.cpp
@@ -36,10 +36,10 @@
#include "mongo/base/data_type_endian.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/rpc/message.h"
#include "mongo/transport/message_compressor_registry.h"
#include "mongo/transport/session.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
namespace mongo {
namespace {
diff --git a/src/mongo/transport/message_compressor_manager_test.cpp b/src/mongo/transport/message_compressor_manager_test.cpp
index 5cc6010716e..299519ab9a9 100644
--- a/src/mongo/transport/message_compressor_manager_test.cpp
+++ b/src/mongo/transport/message_compressor_manager_test.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/rpc/message.h"
#include "mongo/stdx/memory.h"
#include "mongo/transport/message_compressor_manager.h"
#include "mongo/transport/message_compressor_noop.h"
@@ -39,7 +40,6 @@
#include "mongo/transport/message_compressor_zlib.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
#include <string>
#include <vector>
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp
index 2f45bee0cbb..d2b423d6c34 100644
--- a/src/mongo/transport/service_state_machine.cpp
+++ b/src/mongo/transport/service_state_machine.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/client.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/stats/counters.h"
+#include "mongo/rpc/message.h"
#include "mongo/stdx/memory.h"
#include "mongo/transport/message_compressor_manager.h"
#include "mongo/transport/service_entry_point.h"
@@ -48,7 +49,6 @@
#include "mongo/util/debug_util.h"
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/net/socket_exception.h"
#include "mongo/util/quick_exit.h"
diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp
index 0cc4aa0634a..7ea13eaf12f 100644
--- a/src/mongo/transport/service_state_machine_test.cpp
+++ b/src/mongo/transport/service_state_machine_test.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/client.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/service_context_noop.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/stdx/memory.h"
#include "mongo/transport/mock_session.h"
#include "mongo/transport/service_entry_point.h"
@@ -47,7 +48,6 @@
#include "mongo/util/assert_util.h"
#include "mongo/util/clock_source_mock.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/tick_source_mock.h"
namespace mongo {
diff --git a/src/mongo/transport/session.h b/src/mongo/transport/session.h
index 304c8f11da4..5cbf7f54c81 100644
--- a/src/mongo/transport/session.h
+++ b/src/mongo/transport/session.h
@@ -32,11 +32,11 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/rpc/message.h"
#include "mongo/transport/session_id.h"
#include "mongo/util/decorable.h"
#include "mongo/util/future.h"
#include "mongo/util/net/hostandport.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/transport/session_asio.h b/src/mongo/transport/session_asio.h
index 5f02ec48eb8..1d6f9d4bf8a 100644
--- a/src/mongo/transport/session_asio.h
+++ b/src/mongo/transport/session_asio.h
@@ -37,7 +37,7 @@
#include "mongo/transport/baton.h"
#include "mongo/transport/transport_layer_asio.h"
#include "mongo/util/fail_point.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/socket_utils.h"
#ifdef MONGO_CONFIG_SSL
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/net/ssl_types.h"
diff --git a/src/mongo/transport/transport_layer.h b/src/mongo/transport/transport_layer.h
index ab36f7954a3..88dff32bf48 100644
--- a/src/mongo/transport/transport_layer.h
+++ b/src/mongo/transport/transport_layer.h
@@ -34,7 +34,6 @@
#include "mongo/stdx/functional.h"
#include "mongo/transport/session.h"
#include "mongo/util/future.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp
index c194073d000..92d6678c73c 100644
--- a/src/mongo/transport/transport_layer_asio.cpp
+++ b/src/mongo/transport/transport_layer_asio.cpp
@@ -45,8 +45,6 @@
#include "mongo/transport/service_entry_point.h"
#include "mongo/util/log.h"
#include "mongo/util/net/hostandport.h"
-#include "mongo/util/net/message.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/sockaddr.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/net/ssl_options.h"
diff --git a/src/mongo/transport/transport_layer_asio_test.cpp b/src/mongo/transport/transport_layer_asio_test.cpp
index 1d1dec75c98..b9ff5580dc4 100644
--- a/src/mongo/transport/transport_layer_asio_test.cpp
+++ b/src/mongo/transport/transport_layer_asio_test.cpp
@@ -32,11 +32,11 @@
#include "mongo/transport/transport_layer_asio.h"
#include "mongo/db/server_options.h"
+#include "mongo/rpc/op_msg.h"
#include "mongo/transport/service_entry_point.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/op_msg.h"
#include "mongo/util/net/sock.h"
#include "asio.hpp"
diff --git a/src/mongo/transport/transport_layer_manager.h b/src/mongo/transport/transport_layer_manager.h
index 18df98e99cd..69bfa6ff8c2 100644
--- a/src/mongo/transport/transport_layer_manager.h
+++ b/src/mongo/transport/transport_layer_manager.h
@@ -34,7 +34,6 @@
#include "mongo/stdx/mutex.h"
#include "mongo/transport/session.h"
#include "mongo/transport/transport_layer.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/transport/transport_layer_mock.cpp b/src/mongo/transport/transport_layer_mock.cpp
index 6b23127e80f..50cf529d545 100644
--- a/src/mongo/transport/transport_layer_mock.cpp
+++ b/src/mongo/transport/transport_layer_mock.cpp
@@ -34,7 +34,6 @@
#include "mongo/stdx/memory.h"
#include "mongo/transport/mock_session.h"
#include "mongo/transport/transport_layer.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/time_support.h"
namespace mongo {
diff --git a/src/mongo/transport/transport_layer_mock.h b/src/mongo/transport/transport_layer_mock.h
index 001c2bd76fa..006269242eb 100644
--- a/src/mongo/transport/transport_layer_mock.h
+++ b/src/mongo/transport/transport_layer_mock.h
@@ -32,7 +32,6 @@
#include "mongo/stdx/unordered_map.h"
#include "mongo/transport/session.h"
#include "mongo/transport/transport_layer.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/net/ssl_types.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/unittest/SConscript b/src/mongo/unittest/SConscript
index dbc359e6787..4645c23c19a 100644
--- a/src/mongo/unittest/SConscript
+++ b/src/mongo/unittest/SConscript
@@ -4,38 +4,52 @@ Import("env")
env = env.Clone()
-env.Library(target="unittest",
- source=[
- 'bson_test_util.cpp',
- 'death_test.cpp',
- 'temp_dir.cpp',
- 'unittest.cpp',
- 'unittest_helpers.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/db/server_options_core',
- '$BUILD_DIR/mongo/util/options_parser/options_parser',
- ])
+env.Library(
+ target="unittest",
+ source=[
+ 'bson_test_util.cpp',
+ 'death_test.cpp',
+ 'temp_dir.cpp',
+ 'unittest.cpp',
+ 'unittest_helpers.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/base',
+ ],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/server_options_core',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser',
+ ],
+)
-env.Library("unittest_main", ['unittest_main.cpp'],
- LIBDEPS=[
- 'unittest',
- ])
+env.Library(
+ target="unittest_main",
+ source=[
+ 'unittest_main.cpp'
+ ],
+ LIBDEPS=[
+ 'unittest',
+ ],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/util/options_parser/options_parser',
+ ],
+)
-env.Library(target="integration_test_main",
- source=[
- 'integration_test_main.cpp',
- ],
- LIBDEPS=[
- 'unittest',
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/client/connection_string',
- '$BUILD_DIR/mongo/util/options_parser/options_parser_init',
- ],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/transport/transport_layer_egress_init',
- ],
+env.Library(
+ target="integration_test_main",
+ source=[
+ 'integration_test_main.cpp',
+ ],
+ LIBDEPS=[
+ 'unittest',
+ '$BUILD_DIR/mongo/base',
+ ],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/client/connection_string',
+ '$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/transport/transport_layer_egress_init',
+ '$BUILD_DIR/mongo/util/options_parser/options_parser_init',
+ ],
)
bmEnv = env.Clone()
diff --git a/src/mongo/util/net/SConscript b/src/mongo/util/net/SConscript
index 818a1344331..33a868e0b21 100644
--- a/src/mongo/util/net/SConscript
+++ b/src/mongo/util/net/SConscript
@@ -6,95 +6,75 @@ Import('ssl_provider')
env = env.Clone()
env.Library(
- target='host',
+ target='network',
source=[
"cidr.cpp",
"hostandport.cpp",
"hostname_canonicalization.cpp",
"sockaddr.cpp",
+ "socket_exception.cpp",
+ "socket_utils.cpp",
env.Idlc('hostandport.idl')[0],
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/server_options_core',
+ '$BUILD_DIR/mongo/util/concurrency/spin_lock',
+ '$BUILD_DIR/mongo/util/winutil',
+ ],
)
env.Library(
- target='network',
+ target='ssl_manager',
source=[
- "message.cpp",
- "op_msg.cpp",
"private/socket_poll.cpp",
"private/ssl_expiration.cpp",
"sock.cpp",
- "socket_exception.cpp",
"ssl_manager.cpp",
- 'ssl_manager_%s.cpp' % (ssl_provider),
"ssl_options.cpp",
"ssl_parameters.cpp",
+ "ssl_manager_%s.cpp" % (ssl_provider),
+ "ssl_stream.cpp",
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/auth/auth_rolename',
- '$BUILD_DIR/mongo/util/concurrency/ticketholder',
- 'host',
+ '$BUILD_DIR/third_party/shim_asio',
+ 'network',
],
LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/crypto/sha_block_${MONGO_CRYPTO}',
'$BUILD_DIR/mongo/db/auth/authcommon',
- '$BUILD_DIR/mongo/db/bson/dotted_path_support',
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/util/background_job',
'$BUILD_DIR/mongo/util/fail_point',
'$BUILD_DIR/mongo/util/options_parser/options_parser',
'$BUILD_DIR/mongo/util/winutil',
- 'ssl_stream',
],
)
-env.Library(
- target="ssl_stream",
- source=[
- "ssl_stream.cpp"],
- LIBDEPS=[
- '$BUILD_DIR/third_party/shim_asio',
- ]
-)
-
env.CppUnitTest(
target='network_test',
source=[
'cidr_test.cpp',
'hostandport_test.cpp',
- 'op_msg_test.cpp',
- 'sock_test.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/util/fail_point',
'network',
],
)
-
env.CppUnitTest(
target='ssl_manager_test',
source=[
'ssl_manager_test.cpp',
'ssl_options_test.cpp',
+ 'sock_test.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- 'network',
- ],
-)
-
-env.CppIntegrationTest(
- target='op_msg_integration_test',
- source=[
- 'op_msg_integration_test.cpp',
- ],
- LIBDEPS=[
- 'network',
- '$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/util/version_impl',
+ '$BUILD_DIR/mongo/util/fail_point',
+ 'ssl_manager',
],
)
diff --git a/src/mongo/util/net/hostname_canonicalization.cpp b/src/mongo/util/net/hostname_canonicalization.cpp
index 5b776740933..bef16a67178 100644
--- a/src/mongo/util/net/hostname_canonicalization.cpp
+++ b/src/mongo/util/net/hostname_canonicalization.cpp
@@ -41,7 +41,7 @@
#endif
#include "mongo/util/log.h"
-#include "mongo/util/net/sock.h"
+#include "mongo/util/net/sockaddr.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp
index 5be8daf6554..1935ca1046e 100644
--- a/src/mongo/util/net/sock.cpp
+++ b/src/mongo/util/net/sock.cpp
@@ -64,11 +64,10 @@
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/util/net/message.h"
#include "mongo/util/net/private/socket_poll.h"
#include "mongo/util/net/socket_exception.h"
+#include "mongo/util/net/socket_utils.h"
#include "mongo/util/net/ssl_manager.h"
-#include "mongo/util/quick_exit.h"
#include "mongo/util/winutil.h"
namespace mongo {
@@ -110,17 +109,6 @@ void networkWarnWithDescription(const Socket& socket, StringData call, int error
const double kMaxConnectTimeoutMS = 5000;
-
-} // namespace
-
-static bool ipv6 = false;
-void enableIPv6(bool state) {
- ipv6 = state;
-}
-bool IPv6Enabled() {
- return ipv6;
-}
-
void setSockTimeouts(int sock, double secs) {
bool report = shouldLog(logger::LogSeverity::Debug(4));
DEV report = true;
@@ -146,96 +134,6 @@ void setSockTimeouts(int sock, double secs) {
#endif
}
-#ifdef _WIN32
-#ifdef _UNICODE
-#define X_STR_CONST(str) (L##str)
-#else
-#define X_STR_CONST(str) (str)
-#endif
-const CString kKeepAliveGroup(
- X_STR_CONST("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"));
-const CString kKeepAliveTime(X_STR_CONST("KeepAliveTime"));
-const CString kKeepAliveInterval(X_STR_CONST("KeepAliveInterval"));
-#undef X_STR_CONST
-#endif
-
-void setSocketKeepAliveParams(int sock,
- unsigned int maxKeepIdleSecs,
- unsigned int maxKeepIntvlSecs) {
-#ifdef _WIN32
- // Defaults per MSDN when registry key does not exist.
- // Expressed in seconds here to be consistent with posix,
- // though Windows uses milliseconds.
- const DWORD kWindowsKeepAliveTimeSecsDefault = 2 * 60 * 60;
- const DWORD kWindowsKeepAliveIntervalSecsDefault = 1;
-
- const auto getKey = [](const CString& key, DWORD default_value) {
- auto withval = windows::getDWORDRegistryKey(kKeepAliveGroup, key);
- if (withval.isOK()) {
- auto val = withval.getValue();
- // Return seconds
- return val ? (val.get() / 1000) : default_value;
- }
- error() << "can't get KeepAlive parameter: " << withval.getStatus();
- return default_value;
- };
-
- const auto keepIdleSecs = getKey(kKeepAliveTime, kWindowsKeepAliveTimeSecsDefault);
- const auto keepIntvlSecs = getKey(kKeepAliveInterval, kWindowsKeepAliveIntervalSecsDefault);
-
- if ((keepIdleSecs > maxKeepIdleSecs) || (keepIntvlSecs > maxKeepIntvlSecs)) {
- DWORD sent = 0;
- struct tcp_keepalive keepalive;
- keepalive.onoff = TRUE;
- keepalive.keepalivetime = std::min<DWORD>(keepIdleSecs, maxKeepIdleSecs) * 1000;
- keepalive.keepaliveinterval = std::min<DWORD>(keepIntvlSecs, maxKeepIntvlSecs) * 1000;
- if (WSAIoctl(sock,
- SIO_KEEPALIVE_VALS,
- &keepalive,
- sizeof(keepalive),
- nullptr,
- 0,
- &sent,
- nullptr,
- nullptr)) {
- error() << "failed setting keepalive values: " << WSAGetLastError();
- }
- }
-#elif defined(__APPLE__) || defined(__linux__)
- const auto updateSockOpt =
- [sock](int level, int optnum, unsigned int maxval, StringData optname) {
- unsigned int optval = 1;
- socklen_t len = sizeof(optval);
-
- if (getsockopt(sock, level, optnum, (char*)&optval, &len)) {
- error() << "can't get " << optname << ": " << errnoWithDescription();
- }
-
- if (optval > maxval) {
- optval = maxval;
- if (setsockopt(sock, level, optnum, (char*)&optval, sizeof(optval))) {
- error() << "can't set " << optname << ": " << errnoWithDescription();
- }
- }
- };
-
-#ifdef __APPLE__
- updateSockOpt(IPPROTO_TCP, TCP_KEEPALIVE, maxKeepIdleSecs, "TCP_KEEPALIVE");
-#endif
-
-#ifdef __linux__
-#ifdef SOL_TCP
- const int level = SOL_TCP;
-#else
- const int level = SOL_SOCKET;
-#endif
- updateSockOpt(level, TCP_KEEPIDLE, maxKeepIdleSecs, "TCP_KEEPIDLE");
- updateSockOpt(level, TCP_KEEPINTVL, maxKeepIntvlSecs, "TCP_KEEPINTVL");
-#endif
-
-#endif
-}
-
void disableNagle(int sock) {
int x = 1;
#ifdef _WIN32
@@ -257,68 +155,7 @@ void disableNagle(int sock) {
setSocketKeepAliveParams(sock);
}
-// --- SockAddr
-
-string makeUnixSockPath(int port) {
- return mongoutils::str::stream() << serverGlobalParams.socket << "/mongodb-" << port << ".sock";
-}
-
-
-// If an ip address is passed in, just return that. If a hostname is passed
-// in, look up its ip and return that. Returns "" on failure.
-string hostbyname(const char* hostname) {
- SockAddr sockAddr(hostname, 0, IPv6Enabled() ? AF_UNSPEC : AF_INET);
- if (!sockAddr.isValid() || sockAddr.getAddr() == "0.0.0.0")
- return "";
- else
- return sockAddr.getAddr();
-}
-
-// --- my --
-
-DiagStr& _hostNameCached = *(new DiagStr); // this is also written to from commands/cloud.cpp
-
-string getHostName() {
- char buf[256];
- int ec = gethostname(buf, 127);
- if (ec || *buf == 0) {
- log() << "can't get this server's hostname " << errnoWithDescription();
- return "";
- }
- return buf;
-}
-
-/** we store our host name once */
-string getHostNameCached() {
- string temp = _hostNameCached.get();
- if (_hostNameCached.empty()) {
- temp = getHostName();
- _hostNameCached = temp;
- }
- return temp;
-}
-
-string getHostNameCachedAndPort() {
- return str::stream() << getHostNameCached() << ':' << serverGlobalParams.port;
-}
-
-string prettyHostName() {
- return (serverGlobalParams.port == ServerGlobalParams::DefaultDBPort
- ? getHostNameCached()
- : getHostNameCachedAndPort());
-}
-
-#ifdef MSG_NOSIGNAL
-const int portSendFlags = MSG_NOSIGNAL;
-const int portRecvFlags = MSG_NOSIGNAL;
-#else
-const int portSendFlags = 0;
-const int portRecvFlags = 0;
-#endif
-
-// ------------ Socket -----------------
-
-static int socketGetLastError() {
+int socketGetLastError() {
#ifdef _WIN32
return WSAGetLastError();
#else
@@ -326,7 +163,7 @@ static int socketGetLastError() {
#endif
}
-static SockAddr getLocalAddrForBoundSocketFd(int fd) {
+SockAddr getLocalAddrForBoundSocketFd(int fd) {
SockAddr result;
int rc = getsockname(fd, result.raw(), &result.addressSize);
if (rc != 0) {
@@ -337,6 +174,18 @@ static SockAddr getLocalAddrForBoundSocketFd(int fd) {
return result;
}
+} // namespace
+
+#ifdef MSG_NOSIGNAL
+const int portSendFlags = MSG_NOSIGNAL;
+const int portRecvFlags = MSG_NOSIGNAL;
+#else
+const int portSendFlags = 0;
+const int portRecvFlags = 0;
+#endif
+
+// ------------ Socket -----------------
+
Socket::Socket(int fd, const SockAddr& remote)
: _fd(fd),
_remote(remote),
@@ -866,16 +715,4 @@ bool Socket::isStillConnected() {
return false;
}
-#if defined(_WIN32)
-struct WinsockInit {
- WinsockInit() {
- WSADATA d;
- if (WSAStartup(MAKEWORD(2, 2), &d) != 0) {
- log() << "ERROR: wsastartup failed " << errnoWithDescription();
- quickExit(EXIT_NTSERVICE_ERROR);
- }
- }
-} winsock_init;
-#endif
-
} // namespace mongo
diff --git a/src/mongo/util/net/sock.h b/src/mongo/util/net/sock.h
index 5c7d01a64ef..3ecb0d31202 100644
--- a/src/mongo/util/net/sock.h
+++ b/src/mongo/util/net/sock.h
@@ -68,11 +68,6 @@ struct SSLPeerInfo;
extern const int portSendFlags;
extern const int portRecvFlags;
-void setSocketKeepAliveParams(int sock,
- unsigned int maxKeepIdleSecs = 300,
- unsigned int maxKeepIntvlSecs = 300);
-void disableNagle(int sock);
-
#if !defined(_WIN32)
inline void closesocket(int s) {
@@ -83,29 +78,6 @@ typedef int SOCKET;
#endif // _WIN32
-std::string makeUnixSockPath(int port);
-
-// If an ip address is passed in, just return that. If a hostname is passed
-// in, look up its ip and return that. Returns "" on failure.
-std::string hostbyname(const char* hostname);
-
-void enableIPv6(bool state = true);
-bool IPv6Enabled();
-void setSockTimeouts(int sock, double secs);
-
-/** this is not cache and does a syscall */
-std::string getHostName();
-
-/** this is cached, so if changes during the process lifetime
- * will be stale */
-std::string getHostNameCached();
-
-/** Returns getHostNameCached():<port>. */
-std::string getHostNameCachedAndPort();
-
-/** Returns getHostNameCached(), or getHostNameCached():<port> if running on a non-default port. */
-std::string prettyHostName();
-
/**
* thin wrapped around file descriptor and system calls
* todo: ssl
@@ -270,5 +242,4 @@ private:
bool _awaitingHandshake;
};
-
} // namespace mongo
diff --git a/src/mongo/util/net/socket_utils.cpp b/src/mongo/util/net/socket_utils.cpp
new file mode 100644
index 00000000000..b36f24c597f
--- /dev/null
+++ b/src/mongo/util/net/socket_utils.cpp
@@ -0,0 +1,223 @@
+/* Copyright 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/util/net/socket_utils.h"
+
+#if !defined(_WIN32)
+#include <arpa/inet.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <poll.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#if defined(__OpenBSD__)
+#include <sys/uio.h>
+#endif
+#else
+#include <mstcpip.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
+#include "mongo/db/server_options.h"
+#include "mongo/util/concurrency/value.h"
+#include "mongo/util/errno_util.h"
+#include "mongo/util/log.h"
+#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/net/sockaddr.h"
+#include "mongo/util/quick_exit.h"
+#include "mongo/util/winutil.h"
+
+namespace mongo {
+
+#if defined(_WIN32)
+const struct WinsockInit {
+ WinsockInit() {
+ WSADATA d;
+ if (WSAStartup(MAKEWORD(2, 2), &d) != 0) {
+ log() << "ERROR: wsastartup failed " << errnoWithDescription();
+ quickExit(EXIT_NTSERVICE_ERROR);
+ }
+ }
+} winsock_init;
+#endif
+
+static bool ipv6 = false;
+void enableIPv6(bool state) {
+ ipv6 = state;
+}
+bool IPv6Enabled() {
+ return ipv6;
+}
+
+#ifdef _WIN32
+#ifdef _UNICODE
+#define X_STR_CONST(str) (L##str)
+#else
+#define X_STR_CONST(str) (str)
+#endif
+const CString kKeepAliveGroup(
+ X_STR_CONST("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"));
+const CString kKeepAliveTime(X_STR_CONST("KeepAliveTime"));
+const CString kKeepAliveInterval(X_STR_CONST("KeepAliveInterval"));
+#undef X_STR_CONST
+#endif
+
+void setSocketKeepAliveParams(int sock,
+ unsigned int maxKeepIdleSecs,
+ unsigned int maxKeepIntvlSecs) {
+#ifdef _WIN32
+ // Defaults per MSDN when registry key does not exist.
+ // Expressed in seconds here to be consistent with posix,
+ // though Windows uses milliseconds.
+ const DWORD kWindowsKeepAliveTimeSecsDefault = 2 * 60 * 60;
+ const DWORD kWindowsKeepAliveIntervalSecsDefault = 1;
+
+ const auto getKey = [](const CString& key, DWORD default_value) {
+ auto withval = windows::getDWORDRegistryKey(kKeepAliveGroup, key);
+ if (withval.isOK()) {
+ auto val = withval.getValue();
+ // Return seconds
+ return val ? (val.get() / 1000) : default_value;
+ }
+ error() << "can't get KeepAlive parameter: " << withval.getStatus();
+ return default_value;
+ };
+
+ const auto keepIdleSecs = getKey(kKeepAliveTime, kWindowsKeepAliveTimeSecsDefault);
+ const auto keepIntvlSecs = getKey(kKeepAliveInterval, kWindowsKeepAliveIntervalSecsDefault);
+
+ if ((keepIdleSecs > maxKeepIdleSecs) || (keepIntvlSecs > maxKeepIntvlSecs)) {
+ DWORD sent = 0;
+ struct tcp_keepalive keepalive;
+ keepalive.onoff = TRUE;
+ keepalive.keepalivetime = std::min<DWORD>(keepIdleSecs, maxKeepIdleSecs) * 1000;
+ keepalive.keepaliveinterval = std::min<DWORD>(keepIntvlSecs, maxKeepIntvlSecs) * 1000;
+ if (WSAIoctl(sock,
+ SIO_KEEPALIVE_VALS,
+ &keepalive,
+ sizeof(keepalive),
+ nullptr,
+ 0,
+ &sent,
+ nullptr,
+ nullptr)) {
+ error() << "failed setting keepalive values: " << WSAGetLastError();
+ }
+ }
+#elif defined(__APPLE__) || defined(__linux__)
+ const auto updateSockOpt =
+ [sock](int level, int optnum, unsigned int maxval, StringData optname) {
+ unsigned int optval = 1;
+ socklen_t len = sizeof(optval);
+
+ if (getsockopt(sock, level, optnum, (char*)&optval, &len)) {
+ error() << "can't get " << optname << ": " << errnoWithDescription();
+ }
+
+ if (optval > maxval) {
+ optval = maxval;
+ if (setsockopt(sock, level, optnum, (char*)&optval, sizeof(optval))) {
+ error() << "can't set " << optname << ": " << errnoWithDescription();
+ }
+ }
+ };
+
+#ifdef __APPLE__
+ updateSockOpt(IPPROTO_TCP, TCP_KEEPALIVE, maxKeepIdleSecs, "TCP_KEEPALIVE");
+#endif
+
+#ifdef __linux__
+#ifdef SOL_TCP
+ const int level = SOL_TCP;
+#else
+ const int level = SOL_SOCKET;
+#endif
+ updateSockOpt(level, TCP_KEEPIDLE, maxKeepIdleSecs, "TCP_KEEPIDLE");
+ updateSockOpt(level, TCP_KEEPINTVL, maxKeepIntvlSecs, "TCP_KEEPINTVL");
+#endif
+
+#endif
+}
+
+std::string makeUnixSockPath(int port) {
+ return mongoutils::str::stream() << serverGlobalParams.socket << "/mongodb-" << port << ".sock";
+}
+
+// If an ip address is passed in, just return that. If a hostname is passed
+// in, look up its ip and return that. Returns "" on failure.
+std::string hostbyname(const char* hostname) {
+ SockAddr sockAddr(hostname, 0, IPv6Enabled() ? AF_UNSPEC : AF_INET);
+ if (!sockAddr.isValid() || sockAddr.getAddr() == "0.0.0.0")
+ return "";
+ else
+ return sockAddr.getAddr();
+}
+
+// --- my --
+
+DiagStr& _hostNameCached = *(new DiagStr); // this is also written to from commands/cloud.cpp
+
+std::string getHostName() {
+ char buf[256];
+ int ec = gethostname(buf, 127);
+ if (ec || *buf == 0) {
+ log() << "can't get this server's hostname " << errnoWithDescription();
+ return "";
+ }
+ return buf;
+}
+
+/** we store our host name once */
+std::string getHostNameCached() {
+ std::string temp = _hostNameCached.get();
+ if (_hostNameCached.empty()) {
+ temp = getHostName();
+ _hostNameCached = temp;
+ }
+ return temp;
+}
+
+std::string getHostNameCachedAndPort() {
+ return str::stream() << getHostNameCached() << ':' << serverGlobalParams.port;
+}
+
+std::string prettyHostName() {
+ return (serverGlobalParams.port == ServerGlobalParams::DefaultDBPort
+ ? getHostNameCached()
+ : getHostNameCachedAndPort());
+}
+
+} // namespace mongo
diff --git a/src/mongo/util/net/socket_utils.h b/src/mongo/util/net/socket_utils.h
new file mode 100644
index 00000000000..d3aad2092d7
--- /dev/null
+++ b/src/mongo/util/net/socket_utils.h
@@ -0,0 +1,61 @@
+/* Copyright 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#pragma once
+
+#include <string>
+
+
+namespace mongo {
+
+void setSocketKeepAliveParams(int sock,
+ unsigned int maxKeepIdleSecs = 300,
+ unsigned int maxKeepIntvlSecs = 300);
+
+std::string makeUnixSockPath(int port);
+
+// If an ip address is passed in, just return that. If a hostname is passed
+// in, look up its ip and return that. Returns "" on failure.
+std::string hostbyname(const char* hostname);
+
+void enableIPv6(bool state = true);
+bool IPv6Enabled();
+
+/** this is not cache and does a syscall */
+std::string getHostName();
+
+/** this is cached, so if changes during the process lifetime
+ * will be stale */
+std::string getHostNameCached();
+
+/** Returns getHostNameCached():<port>. */
+std::string getHostNameCachedAndPort();
+
+/** Returns getHostNameCached(), or getHostNameCached():<port> if running on a non-default port. */
+std::string prettyHostName();
+
+} // namespace mongo
diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp
index e13ce17067c..0d9c7acc14e 100644
--- a/src/mongo/util/net/ssl_manager_openssl.cpp
+++ b/src/mongo/util/net/ssl_manager_openssl.cpp
@@ -55,7 +55,6 @@
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/private/ssl_expiration.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/socket_exception.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/net/ssl_types.h"
diff --git a/src/mongo/util/net/ssl_manager_windows.cpp b/src/mongo/util/net/ssl_manager_windows.cpp
index 8e32993c752..15b08369f9b 100644
--- a/src/mongo/util/net/ssl_manager_windows.cpp
+++ b/src/mongo/util/net/ssl_manager_windows.cpp
@@ -53,7 +53,6 @@
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/private/ssl_expiration.h"
-#include "mongo/util/net/sock.h"
#include "mongo/util/net/socket_exception.h"
#include "mongo/util/net/ssl.hpp"
#include "mongo/util/net/ssl_options.h"
diff --git a/src/mongo/util/net/ssl_options.cpp b/src/mongo/util/net/ssl_options.cpp
index 50f6f7d6671..dd8a28de553 100644
--- a/src/mongo/util/net/ssl_options.cpp
+++ b/src/mongo/util/net/ssl_options.cpp
@@ -41,6 +41,10 @@
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/text.h"
+#if MONGO_CONFIG_SSL_PROVIDER == SSL_PROVIDER_OPENSSL
+#include <openssl/ssl.h>
+#endif // #ifdef MONGO_CONFIG_SSL
+
namespace mongo {
namespace moe = mongo::optionenvironment;
diff --git a/src/mongo/util/net/ssl_options.h b/src/mongo/util/net/ssl_options.h
index 721d713e24b..19898c2f0ed 100644
--- a/src/mongo/util/net/ssl_options.h
+++ b/src/mongo/util/net/ssl_options.h
@@ -27,8 +27,7 @@
#pragma once
-#include "mongo/util/net/ssl_manager.h"
-
+#include <string>
#include <vector>
#include "mongo/base/status.h"