diff options
author | stanly <stanly@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
commit | cde218e65dfef5ce03a48d641fd8f7913cf17b2d (patch) | |
tree | d3349caea4095825a55b5ba24fe758067b29ce6f /library/cpp/messagebus/locator.cpp | |
parent | 9f813499b4ef585cb3c2bb93de93ef003daf4fc4 (diff) | |
download | ydb-cde218e65dfef5ce03a48d641fd8f7913cf17b2d.tar.gz |
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/locator.cpp')
-rw-r--r-- | library/cpp/messagebus/locator.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/library/cpp/messagebus/locator.cpp b/library/cpp/messagebus/locator.cpp index e38a35c426..242b9b3120 100644 --- a/library/cpp/messagebus/locator.cpp +++ b/library/cpp/messagebus/locator.cpp @@ -7,8 +7,8 @@ #include "ybus.h" #include <util/generic/hash_set.h> -#include <util/system/hostname.h> - +#include <util/system/hostname.h> + namespace NBus { using namespace NAddr; @@ -17,7 +17,7 @@ namespace NBus { case AF_INET: { return ntohs(((const sockaddr_in*)addr.Addr())->sin_port); } - + case AF_INET6: { return ntohs(((const sockaddr_in6*)addr.Addr())->sin6_port); } @@ -26,9 +26,9 @@ namespace NBus { ythrow yexception() << "not implemented"; break; } - } + } } - + static inline bool GetIp6AddressFromVector(const TVector<TNetAddr>& addrs, TNetAddr* addr) { for (size_t i = 1; i < addrs.size(); ++i) { if (addrs[i - 1].Addr()->sa_family == addrs[i].Addr()->sa_family) { @@ -38,18 +38,18 @@ namespace NBus { if (GetAddrPort(addrs[i - 1]) != GetAddrPort(addrs[i])) { return false; } - } - + } + for (size_t i = 0; i < addrs.size(); ++i) { if (addrs[i].Addr()->sa_family == AF_INET6) { *addr = addrs[i]; return true; } - } + } return false; - } - + } + EMessageStatus TBusProtocol::GetDestination(const TBusClientSession*, TBusMessage* mess, TBusLocator* locator, TNetAddr* addr) { TBusService service = GetService(); TBusKey key = GetKey(mess); @@ -61,8 +61,8 @@ namespace NBus { } else { /// lookup address/port in the locator table locator->LocateAll(service, key, addrs); - } - + } + if (addrs.size() == 0) { return MESSAGE_SERVICE_UNKNOWN; } else if (addrs.size() == 1) { @@ -73,15 +73,15 @@ namespace NBus { /// to implement custom routing strategy for your service. return MESSAGE_SERVICE_TOOMANY; } - } + } return MESSAGE_OK; - } - + } + static const sockaddr_in* SockAddrIpV4(const IRemoteAddr& a) { return (const sockaddr_in*)a.Addr(); - } - + } + static const sockaddr_in6* SockAddrIpV6(const IRemoteAddr& a) { return (const sockaddr_in6*)a.Addr(); } @@ -96,7 +96,7 @@ namespace NBus { } return false; } - + TBusLocator::TBusLocator() : MyInterfaces(GetNetworkInterfaces()) { @@ -137,7 +137,7 @@ namespace NBus { const char* c = ServiceIdSet.insert(name).first->c_str(); return (ui64)c; } - + int TBusLocator::RegisterBreak(TBusService service, const TVector<TBusKey>& starts, const TNetAddr& addr) { TGuard<TMutex> G(Lock); @@ -399,7 +399,7 @@ namespace NBus { TServiceId serviceId = GetServiceId(service); TItems::const_iterator it; - + TItem itemToReg(serviceId, start, end, addr); for (it = Items.lower_bound(TItem(serviceId, 0, start, TNetAddr())); it != Items.end() && it->ServiceId == serviceId; |