diff options
| author | Andrey Fomichev <[email protected]> | 2022-02-10 16:49:15 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:15 +0300 | 
| commit | 1c61afbf3db63940d05e6fefa3104b03457788a1 (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/testing/unittest | |
| parent | e542cc14db4240643a06bb0dde87ecf361f101ab (diff) | |
Restoring authorship annotation for Andrey Fomichev <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/unittest')
| -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 6775e98b5da..6536bc1ae69 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);  | 
