aboutsummaryrefslogtreecommitdiffstats
path: root/util/network/socket.cpp
diff options
context:
space:
mode:
authorcerevra <cerevra@yandex-team.ru>2022-02-10 16:45:59 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:59 +0300
commit4f292c7e2fd0a41da93fda51b2d440c979a330b7 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/network/socket.cpp
parentbf41dd01f6c920583e9faae7cd55ed25e547e052 (diff)
downloadydb-4f292c7e2fd0a41da93fda51b2d440c979a330b7.tar.gz
Restoring authorship annotation for <cerevra@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/network/socket.cpp')
-rw-r--r--util/network/socket.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 6a7d3a9d28..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -490,44 +490,44 @@ void SetTcpFastOpen(SOCKET s, int qlen) {
#endif
}
-static bool IsBlocked(int lasterr) noexcept {
- return lasterr == EAGAIN || lasterr == EWOULDBLOCK;
-}
-
-struct TUnblockingGuard {
- SOCKET S_;
-
- TUnblockingGuard(SOCKET s)
- : S_(s)
- {
- SetNonBlock(S_, true);
- }
-
- ~TUnblockingGuard() {
- SetNonBlock(S_, false);
- }
-};
-
-static int MsgPeek(SOCKET s) {
- int flags = MSG_PEEK;
-
+static bool IsBlocked(int lasterr) noexcept {
+ return lasterr == EAGAIN || lasterr == EWOULDBLOCK;
+}
+
+struct TUnblockingGuard {
+ SOCKET S_;
+
+ TUnblockingGuard(SOCKET s)
+ : S_(s)
+ {
+ SetNonBlock(S_, true);
+ }
+
+ ~TUnblockingGuard() {
+ SetNonBlock(S_, false);
+ }
+};
+
+static int MsgPeek(SOCKET s) {
+ int flags = MSG_PEEK;
+
#if defined(_win_)
- TUnblockingGuard unblocker(s);
- Y_UNUSED(unblocker);
-#else
- flags |= MSG_DONTWAIT;
-#endif
-
- char c;
- return recv(s, &c, 1, flags);
-}
-
-bool IsNotSocketClosedByOtherSide(SOCKET s) {
+ TUnblockingGuard unblocker(s);
+ Y_UNUSED(unblocker);
+#else
+ flags |= MSG_DONTWAIT;
+#endif
+
+ char c;
+ return recv(s, &c, 1, flags);
+}
+
+bool IsNotSocketClosedByOtherSide(SOCKET s) {
return HasSocketDataToRead(s) != ESocketReadStatus::SocketClosed;
}
ESocketReadStatus HasSocketDataToRead(SOCKET s) {
- const int r = MsgPeek(s);
+ const int r = MsgPeek(s);
if (r == -1 && IsBlocked(LastSystemError())) {
return ESocketReadStatus::NoData;
}
@@ -535,9 +535,9 @@ ESocketReadStatus HasSocketDataToRead(SOCKET s) {
return ESocketReadStatus::HasData;
}
return ESocketReadStatus::SocketClosed;
-}
-
-#if defined(_win_)
+}
+
+#if defined(_win_)
static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
return writev(sock, iov, iovcnt);
}
@@ -1097,15 +1097,15 @@ TNetworkResolutionError::TNetworkResolutionError(int error) {
#else
errMsg = gai_strerror(error);
#endif
- (*this) << errMsg << "(" << error;
-
-#if defined(_unix_)
- if (error == EAI_SYSTEM) {
- (*this) << "; errno=" << LastSystemError();
- }
-#endif
-
- (*this) << "): ";
+ (*this) << errMsg << "(" << error;
+
+#if defined(_unix_)
+ if (error == EAI_SYSTEM) {
+ (*this) << "; errno=" << LastSystemError();
+ }
+#endif
+
+ (*this) << "): ";
}
#if defined(_unix_)