aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
diff options
context:
space:
mode:
authorAlexander Rutkovsky <alexvru@mail.ru>2022-02-10 16:47:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:39 +0300
commitf3646f91e0de459836a7800b9ce3e8dc57a2ab3a (patch)
tree25c1423200152570c1f8307e5b8304b9bc3840c5 /library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
parentfccc62e9bfdce9be2fe7e0f23479da3a5512211a (diff)
downloadydb-f3646f91e0de459836a7800b9ce3e8dc57a2ab3a.tar.gz
Restoring authorship annotation for Alexander Rutkovsky <alexvru@mail.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/actors/interconnect/poller_tcp_unit_select.cpp')
-rw-r--r--library/cpp/actors/interconnect/poller_tcp_unit_select.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/actors/interconnect/poller_tcp_unit_select.cpp b/library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
index ae7aaad566..c1b6ae59a1 100644
--- a/library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
+++ b/library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
@@ -1,67 +1,67 @@
-#include "poller_tcp_unit_select.h"
-
-#include <csignal>
-
-#if defined(_win_)
-#include <winsock2.h>
-#define SOCKET_ERROR_SOURCE ::WSAGetLastError()
-#elif defined(_darwin_)
-#include <cerrno>
-#define SOCKET_ERROR_SOURCE errno
-typedef timeval TIMEVAL;
-#else
-#include <cerrno>
-#define SOCKET_ERROR_SOURCE errno
-#endif
-
-namespace NInterconnect {
+#include "poller_tcp_unit_select.h"
+
+#include <csignal>
+
+#if defined(_win_)
+#include <winsock2.h>
+#define SOCKET_ERROR_SOURCE ::WSAGetLastError()
+#elif defined(_darwin_)
+#include <cerrno>
+#define SOCKET_ERROR_SOURCE errno
+typedef timeval TIMEVAL;
+#else
+#include <cerrno>
+#define SOCKET_ERROR_SOURCE errno
+#endif
+
+namespace NInterconnect {
TPollerUnitSelect::TPollerUnitSelect() {
}
-
+
TPollerUnitSelect::~TPollerUnitSelect() {
}
-
+
template <bool IsWrite>
void
TPollerUnitSelect::Process() {
auto& side = GetSide<IsWrite>();
side.ProcessInput();
-
+
enum : size_t { R,
W,
E };
static const auto O = IsWrite ? W : R;
-
+
::fd_set sets[3];
-
+
FD_ZERO(&sets[R]);
FD_ZERO(&sets[W]);
FD_ZERO(&sets[E]);
-
+
for (const auto& operation : side.Operations) {
FD_SET(operation.first, &sets[O]);
FD_SET(operation.first, &sets[E]);
}
-
-#if defined(_win_)
+
+#if defined(_win_)
::TIMEVAL timeout = {0L, 99991L};
const auto numberEvents = !side.Operations.empty() ? ::select(FD_SETSIZE, &sets[R], &sets[W], &sets[E], &timeout)
: (::Sleep(100), 0);
-#elif defined(_darwin_)
+#elif defined(_darwin_)
::TIMEVAL timeout = {0L, 99991L};
const auto numberEvents = ::select(FD_SETSIZE, &sets[R], &sets[W], &sets[E], &timeout);
-#else
+#else
::sigset_t sigmask;
::sigemptyset(&sigmask);
::sigaddset(&sigmask, SIGPIPE);
::sigaddset(&sigmask, SIGTERM);
-
+
struct ::timespec timeout = {0L, 99999989L};
const auto numberEvents = ::pselect(FD_SETSIZE, &sets[R], &sets[W], &sets[E], &timeout, &sigmask);
-#endif
-
+#endif
+
Y_VERIFY_DEBUG(numberEvents >= 0);
-
+
for (auto it = side.Operations.cbegin(); side.Operations.cend() != it;) {
if (FD_ISSET(it->first, &sets[O]) || FD_ISSET(it->first, &sets[E]))
if (const auto& finalizer = it->second.second(it->second.first)) {
@@ -71,16 +71,16 @@ namespace NInterconnect {
}
++it;
}
- }
-
+ }
+
void
TPollerUnitSelect::ProcessRead() {
Process<false>();
}
-
+
void
TPollerUnitSelect::ProcessWrite() {
Process<true>();
}
-
-}
+
+}