diff options
author | Alexey Salmin <alexey.salmin@gmail.com> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
commit | 71af077a5dfe7e9f932a508422c2dac81a57ebc0 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/network/socket.cpp | |
parent | 3c5b1607b38f637d2f3313791ed25c2e080d2647 (diff) | |
download | ydb-71af077a5dfe7e9f932a508422c2dac81a57ebc0.tar.gz |
Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/network/socket.cpp')
-rw-r--r-- | util/network/socket.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 32756f503e..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -1255,43 +1255,43 @@ 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 -} +// 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 +} |