diff options
author | AlexSm <alex@ydb.tech> | 2024-01-18 11:28:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 11:28:56 +0100 |
commit | 9d0a3761b3201e0d9db879a7adf91876ebdb0564 (patch) | |
tree | 541d11ac878c18efd7ebca81e35112aa0fef995b /util | |
parent | 404ef8886ecc9736bc58ade6da2fbd83b486a408 (diff) | |
download | ydb-9d0a3761b3201e0d9db879a7adf91876ebdb0564.tar.gz |
Library import 8 (#1074)
* Library import 8
* Add contrib/libs/cxxsupp/libcxx/include/__verbose_abort
Diffstat (limited to 'util')
-rw-r--r-- | util/network/socket.cpp | 40 | ||||
-rw-r--r-- | util/network/socket.h | 5 | ||||
-rw-r--r-- | util/network/socket_ut.cpp | 29 |
3 files changed, 0 insertions, 74 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp index eaaf0c9cb6..4e9ee24ed2 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -1251,43 +1251,3 @@ void ShutDown(SOCKET s, int mode) { ythrow TSystemError() << "shutdown socket error"; } } - -extern "C" bool IsReusePortAvailable() { -// SO_REUSEPORT is always defined for linux builds, see SetReusePort() implementation above -#if defined(SO_REUSEPORT) - - class TCtx { - public: - TCtx() { - TSocketHolder sock(::socket(AF_INET, SOCK_STREAM, 0)); - const int e1 = errno; - if (sock == INVALID_SOCKET) { - ythrow TSystemError(e1) << "Cannot create AF_INET socket"; - } - int val; - const int ret = GetSockOpt(sock, SOL_SOCKET, SO_REUSEPORT, val); - const int e2 = errno; - if (ret == 0) { - Flag_ = true; - } else { - if (e2 == ENOPROTOOPT) { - Flag_ = false; - } else { - ythrow TSystemError(e2) << "Unexpected error in getsockopt"; - } - } - } - - static inline const TCtx* Instance() noexcept { - return Singleton<TCtx>(); - } - - public: - bool Flag_; - }; - - return TCtx::Instance()->Flag_; -#else - return false; -#endif -} diff --git a/util/network/socket.h b/util/network/socket.h index 40c8648b40..856e707d8a 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -136,11 +136,6 @@ ESocketReadStatus HasSocketDataToRead(SOCKET s); **/ bool HasLocalAddress(SOCKET socket); -/** - * Runtime check if current kernel supports SO_REUSEPORT option. - **/ -extern "C" bool IsReusePortAvailable(); - bool IsNonBlock(SOCKET fd); void SetNonBlock(SOCKET fd, bool nonBlock = true); diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 4ae8f7d41e..b49ca639cc 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -25,7 +25,6 @@ class TSockTest: public TTestBase { UNIT_TEST(TestNetworkResolutionErrorMessage); UNIT_TEST(TestBrokenPipe); UNIT_TEST(TestClose); - UNIT_TEST(TestReusePortAvailCheck); UNIT_TEST_SUITE_END(); public: @@ -36,7 +35,6 @@ public: void TestNetworkResolutionErrorMessage(); void TestBrokenPipe(); void TestClose(); - void TestReusePortAvailCheck(); }; UNIT_TEST_SUITE_REGISTRATION(TSockTest); @@ -185,33 +183,6 @@ void TSockTest::TestClose() { UNIT_ASSERT_EQUAL(static_cast<SOCKET>(receiver), INVALID_SOCKET); } -void TSockTest::TestReusePortAvailCheck() { -#if defined _linux_ - utsname sysInfo; - Y_ABORT_UNLESS(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); - TStringBuf release(sysInfo.release); - release = release.substr(0, release.find_first_not_of(".0123456789")); - int v1 = FromString<int>(release.NextTok('.')); - int v2 = FromString<int>(release.NextTok('.')); - int v3 = FromString<int>(release.NextTok('.')); - int linuxVersionCode = KERNEL_VERSION(v1, v2, v3); - if (linuxVersionCode >= KERNEL_VERSION(3, 9, 1)) { - // new kernels support SO_REUSEPORT - UNIT_ASSERT(true == IsReusePortAvailable()); - UNIT_ASSERT(true == IsReusePortAvailable()); - } else { - // older kernels may or may not support SO_REUSEPORT - // just check that it doesn't crash or throw - (void)IsReusePortAvailable(); - (void)IsReusePortAvailable(); - } -#else - // check that it doesn't crash or throw - (void)IsReusePortAvailable(); - (void)IsReusePortAvailable(); -#endif -} - class TPollTest: public TTestBase { UNIT_TEST_SUITE(TPollTest); UNIT_TEST(TestPollInOut); |