aboutsummaryrefslogtreecommitdiffstats
path: root/util/network/pair.cpp
diff options
context:
space:
mode:
authordvshkurko <dvshkurko@yandex-team.ru>2022-02-10 16:45:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:52 +0300
commitc768a99151e47c3a4bb7b92c514d256abd301c4d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/network/pair.cpp
parent321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff)
downloadydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/network/pair.cpp')
-rw-r--r--util/network/pair.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/util/network/pair.cpp b/util/network/pair.cpp
index e3610aee77..9751ef5c96 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
}