aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus
diff options
context:
space:
mode:
authorAndrey Fomichev <andrey.fomichev@gmail.com>2022-02-10 16:49:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:12 +0300
commite542cc14db4240643a06bb0dde87ecf361f101ab (patch)
tree3b03a4b94acd11a4eca042532035806e5fa08ad1 /library/cpp/messagebus
parente2ac73225f30f7fcf7df3cb225cba257f56144c1 (diff)
downloadydb-e542cc14db4240643a06bb0dde87ecf361f101ab.tar.gz
Restoring authorship annotation for Andrey Fomichev <andrey.fomichev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus')
-rw-r--r--library/cpp/messagebus/network.cpp38
-rw-r--r--library/cpp/messagebus/network_ut.cpp8
-rw-r--r--library/cpp/messagebus/session_impl.cpp2
-rw-r--r--library/cpp/messagebus/test/helper/hanging_server.cpp2
4 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp
index 304bedae5a..a8dc5f6155 100644
--- a/library/cpp/messagebus/network.cpp
+++ b/library/cpp/messagebus/network.cpp
@@ -10,7 +10,7 @@ using namespace NBus;
using namespace NBus::NPrivate;
namespace {
- TBindResult BindOnPortProto(int port, int af, bool reusePort) {
+ TBindResult BindOnPortProto(int port, int af, bool reusePort) {
Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af");
SOCKET fd = ::socket(af, SOCK_STREAM, 0);
@@ -24,17 +24,17 @@ namespace {
ythrow TSystemError() << "failed to setsockopt SO_REUSEADDR";
}
-#ifdef SO_REUSEPORT
- if (reusePort) {
- int r = SetSockOpt(fd, SOL_SOCKET, SO_REUSEPORT, one);
- if (r < 0) {
- ythrow TSystemError() << "failed to setsockopt SO_REUSEPORT";
- }
- }
-#else
- Y_UNUSED(reusePort);
-#endif
-
+#ifdef SO_REUSEPORT
+ if (reusePort) {
+ int r = SetSockOpt(fd, SOL_SOCKET, SO_REUSEPORT, one);
+ if (r < 0) {
+ ythrow TSystemError() << "failed to setsockopt SO_REUSEPORT";
+ }
+ }
+#else
+ Y_UNUSED(reusePort);
+#endif
+
THolder<TOpaqueAddr> addr(new TOpaqueAddr);
sockaddr* sa = addr->MutableAddr();
sa->sa_family = af;
@@ -73,7 +73,7 @@ namespace {
return r;
}
- TMaybe<TBindResult> TryBindOnPortProto(int port, int af, bool reusePort) {
+ TMaybe<TBindResult> TryBindOnPortProto(int port, int af, bool reusePort) {
try {
return {BindOnPortProto(port, af, reusePort)};
} catch (const TSystemError&) {
@@ -93,23 +93,23 @@ namespace {
}
}
-std::pair<unsigned, TVector<TBindResult>> NBus::BindOnPort(int port, bool reusePort) {
+std::pair<unsigned, TVector<TBindResult>> NBus::BindOnPort(int port, bool reusePort) {
std::pair<unsigned, TVector<TBindResult>> r;
r.second.reserve(2);
if (port != 0) {
- return AggregateBindResults(BindOnPortProto(port, AF_INET, reusePort),
+ return AggregateBindResults(BindOnPortProto(port, AF_INET, reusePort),
BindOnPortProto(port, AF_INET6, reusePort));
}
// use nothrow versions in cycle
for (int i = 0; i < 1000; ++i) {
- TMaybe<TBindResult> in4 = TryBindOnPortProto(0, AF_INET, reusePort);
+ TMaybe<TBindResult> in4 = TryBindOnPortProto(0, AF_INET, reusePort);
if (!in4) {
continue;
}
- TMaybe<TBindResult> in6 = TryBindOnPortProto(in4->Addr.GetPort(), AF_INET6, reusePort);
+ TMaybe<TBindResult> in6 = TryBindOnPortProto(in4->Addr.GetPort(), AF_INET6, reusePort);
if (!in6) {
continue;
}
@@ -117,8 +117,8 @@ std::pair<unsigned, TVector<TBindResult>> NBus::BindOnPort(int port, bool reuseP
return AggregateBindResults(std::move(*in4), std::move(*in6));
}
- TBindResult in4 = BindOnPortProto(0, AF_INET, reusePort);
- TBindResult in6 = BindOnPortProto(in4.Addr.GetPort(), AF_INET6, reusePort);
+ TBindResult in4 = BindOnPortProto(0, AF_INET, reusePort);
+ TBindResult in6 = BindOnPortProto(in4.Addr.GetPort(), AF_INET6, reusePort);
return AggregateBindResults(std::move(in4), std::move(in6));
}
diff --git a/library/cpp/messagebus/network_ut.cpp b/library/cpp/messagebus/network_ut.cpp
index f1798419db..d984284bd2 100644
--- a/library/cpp/messagebus/network_ut.cpp
+++ b/library/cpp/messagebus/network_ut.cpp
@@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(Network) {
return;
}
- TVector<TBindResult> r = BindOnPort(FixedPort, false).second;
+ TVector<TBindResult> r = BindOnPort(FixedPort, false).second;
UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size());
for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) {
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(Network) {
}
Y_UNIT_TEST(BindOnPortRandom) {
- TVector<TBindResult> r = BindOnPort(0, false).second;
+ TVector<TBindResult> r = BindOnPort(0, false).second;
UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size());
for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) {
@@ -58,8 +58,8 @@ Y_UNIT_TEST_SUITE(Network) {
}
Y_UNIT_TEST(BindOnBusyPort) {
- auto r = BindOnPort(0, false);
+ auto r = BindOnPort(0, false);
- UNIT_ASSERT_EXCEPTION_CONTAINS(BindOnPort(r.first, false), TSystemError, "failed to bind on port " + ToString(r.first));
+ UNIT_ASSERT_EXCEPTION_CONTAINS(BindOnPort(r.first, false), TSystemError, "failed to bind on port " + ToString(r.first));
}
}
diff --git a/library/cpp/messagebus/session_impl.cpp b/library/cpp/messagebus/session_impl.cpp
index ddf9f360c4..64c9c7e81e 100644
--- a/library/cpp/messagebus/session_impl.cpp
+++ b/library/cpp/messagebus/session_impl.cpp
@@ -484,7 +484,7 @@ void TBusSessionImpl::Act(TConnectionTag) {
}
void TBusSessionImpl::Listen(int port, TBusMessageQueue* q) {
- Listen(BindOnPort(port, Config.ReusePort).second, q);
+ Listen(BindOnPort(port, Config.ReusePort).second, q);
}
void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueue* q) {
diff --git a/library/cpp/messagebus/test/helper/hanging_server.cpp b/library/cpp/messagebus/test/helper/hanging_server.cpp
index a35514b00d..ce09e75273 100644
--- a/library/cpp/messagebus/test/helper/hanging_server.cpp
+++ b/library/cpp/messagebus/test/helper/hanging_server.cpp
@@ -5,7 +5,7 @@
using namespace NBus;
THangingServer::THangingServer(int port) {
- BindResult = BindOnPort(port, false);
+ BindResult = BindOnPort(port, false);
}
int THangingServer::GetPort() const {