diff options
author | Andrey Fomichev <andrey.fomichev@gmail.com> | 2022-02-10 16:49:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:12 +0300 |
commit | e542cc14db4240643a06bb0dde87ecf361f101ab (patch) | |
tree | 3b03a4b94acd11a4eca042532035806e5fa08ad1 /library/cpp/testing/unittest/tests_data.h | |
parent | e2ac73225f30f7fcf7df3cb225cba257f56144c1 (diff) | |
download | ydb-e542cc14db4240643a06bb0dde87ecf361f101ab.tar.gz |
Restoring authorship annotation for Andrey Fomichev <andrey.fomichev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing/unittest/tests_data.h')
-rw-r--r-- | library/cpp/testing/unittest/tests_data.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/testing/unittest/tests_data.h b/library/cpp/testing/unittest/tests_data.h index 6536bc1ae6..6775e98b5d 100644 --- a/library/cpp/testing/unittest/tests_data.h +++ b/library/cpp/testing/unittest/tests_data.h @@ -5,28 +5,28 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> #include <util/generic/string.h> -#include <util/network/sock.h> +#include <util/network/sock.h> class TInet6StreamSocket; -// set two options: SO_REUSEADDR and SO_REUSEPORT, both are required for -// correct implementation of TPortManager because of different operating systems -// incompatibility: singe SO_REUSEADDR is enough for Linux, but not enough for Darwin -template <class TSocketType> -void SetReuseAddressAndPort(const TSocketType& sock) { - const int retAddr = SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1); - if (retAddr < 0) { - ythrow yexception() << "can't set SO_REUSEADDR: " << LastSystemErrorText(-retAddr); - } - -#ifdef SO_REUSEPORT - const int retPort = SetSockOpt(sock, SOL_SOCKET, SO_REUSEPORT, 1); - if (retPort < 0) { - ythrow yexception() << "can't set SO_REUSEPORT: " << LastSystemErrorText(-retPort); - } -#endif -} - +// set two options: SO_REUSEADDR and SO_REUSEPORT, both are required for +// correct implementation of TPortManager because of different operating systems +// incompatibility: singe SO_REUSEADDR is enough for Linux, but not enough for Darwin +template <class TSocketType> +void SetReuseAddressAndPort(const TSocketType& sock) { + const int retAddr = SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1); + if (retAddr < 0) { + ythrow yexception() << "can't set SO_REUSEADDR: " << LastSystemErrorText(-retAddr); + } + +#ifdef SO_REUSEPORT + const int retPort = SetSockOpt(sock, SOL_SOCKET, SO_REUSEPORT, 1); + if (retPort < 0) { + ythrow yexception() << "can't set SO_REUSEPORT: " << LastSystemErrorText(-retPort); + } +#endif +} + class TPortManager: public TNonCopyable { public: TPortManager(bool reservePortsForCurrentTest = true); |