diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
commit | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (patch) | |
tree | 14407a2757cbf29eb97e266b7f07e851f971000c /util/network/pair.cpp | |
parent | 2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (diff) | |
download | ydb-321ee9bce31ec6e238be26dbcbe539cffa2c3309.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/network/pair.cpp')
-rw-r--r-- | util/network/pair.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/util/network/pair.cpp b/util/network/pair.cpp index 9751ef5c96..e3610aee77 100644 --- a/util/network/pair.cpp +++ b/util/network/pair.cpp @@ -1,12 +1,12 @@ #include "pair.h" -int SocketPair(SOCKET socks[2], bool overlapped, bool cloexec) { +int SocketPair(SOCKET socks[2], bool overlapped, bool cloexec) { #if defined(_win_) struct sockaddr_in addr; SOCKET listener; int e; int addrlen = sizeof(addr); - DWORD flags = (overlapped ? WSA_FLAG_OVERLAPPED : 0) | (cloexec ? WSA_FLAG_NO_HANDLE_INHERIT : 0); + DWORD flags = (overlapped ? WSA_FLAG_OVERLAPPED : 0) | (cloexec ? WSA_FLAG_NO_HANDLE_INHERIT : 0); if (socks == 0) { WSASetLastError(WSAEINVAL); @@ -75,23 +75,23 @@ int SocketPair(SOCKET socks[2], bool overlapped, bool cloexec) { (void)overlapped; #if defined(_linux_) - return socketpair(AF_LOCAL, SOCK_STREAM | (cloexec ? SOCK_CLOEXEC : 0), 0, socks); + return socketpair(AF_LOCAL, SOCK_STREAM | (cloexec ? SOCK_CLOEXEC : 0), 0, socks); #else - int r = socketpair(AF_LOCAL, SOCK_STREAM, 0, socks); - // Non-atomic wrt exec - if (r == 0 && cloexec) { - for (int i = 0; i < 2; ++i) { - int flags = fcntl(socks[i], F_GETFD, 0); - if (flags < 0) { - return flags; - } - r = fcntl(socks[i], F_SETFD, flags | FD_CLOEXEC); - if (r < 0) { - return r; - } - } - } - return r; + int r = socketpair(AF_LOCAL, SOCK_STREAM, 0, socks); + // Non-atomic wrt exec + if (r == 0 && cloexec) { + for (int i = 0; i < 2; ++i) { + int flags = fcntl(socks[i], F_GETFD, 0); + if (flags < 0) { + return flags; + } + r = fcntl(socks[i], F_SETFD, flags | FD_CLOEXEC); + if (r < 0) { + return r; + } + } + } + return r; #endif #endif } |