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:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:40 +0300
commit667a4ee7da2e004784b9c3cfab824a81e96f4d66 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/actors/interconnect/poller_tcp_unit_select.cpp
parentf3646f91e0de459836a7800b9ce3e8dc57a2ab3a (diff)
downloadydb-667a4ee7da2e004784b9c3cfab824a81e96f4d66.tar.gz
Restoring authorship annotation for Alexander Rutkovsky <alexvru@mail.ru>. Commit 2 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 c1b6ae59a1..ae7aaad566 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>();
}
-
-}
+
+}