diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-11-19 20:40:27 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-24 02:28:35 +0000 |
commit | 79be0f22b131489173d6d6aa068f0f90f97e338b (patch) | |
tree | 5dd127234d5d0d2a932a11a739f8052149f1fa6f | |
parent | a05141a3e51a8eee3ae620f77f8bf2b7927a8a57 (diff) | |
download | mongo-79be0f22b131489173d6d6aa068f0f90f97e338b.tar.gz |
SERVER-51287 check socket() call for failure
-rw-r--r-- | src/mongo/transport/transport_layer_asio.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index ea4c6c2dcf2..12f21911b56 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -50,6 +50,7 @@ #include "mongo/transport/asio_utils.h" #include "mongo/transport/service_entry_point.h" #include "mongo/transport/transport_options_gen.h" +#include "mongo/util/errno_util.h" #include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/net/sockaddr.h" @@ -732,6 +733,11 @@ namespace { */ bool trySetSockOpt(int level, int opt, int val) { auto sock = ::socket(AF_INET, SOCK_STREAM, 0); + if (sock == -1) { + int ec = errno; + LOGV2_WARNING(5128700, "socket() failed", "error"_attr = errnoWithDescription(ec)); + return false; + } #ifdef _WIN32 char* pval = reinterpret_cast<char*>(&val); |