diff options
author | uzhas <uzhas@yandex-team.ru> | 2022-02-10 16:47:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:07 +0300 |
commit | 531b7c7053348b9d4c8ff3832d1b8db5a1918125 (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 /library/cpp | |
parent | 2002caab389ddffd0e7db4d8c4db835fa4c99f83 (diff) | |
download | ydb-531b7c7053348b9d4c8ff3832d1b8db5a1918125.tar.gz |
Restoring authorship annotation for <uzhas@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/core/event_pb_payload_ut.cpp | 90 | ||||
-rw-r--r-- | library/cpp/grpc/client/grpc_client_low.h | 14 | ||||
-rw-r--r-- | library/cpp/http/server/http.cpp | 16 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value.h | 4 | ||||
-rw-r--r-- | library/cpp/lwtrace/mon/mon_lwtrace.cpp | 10 | ||||
-rw-r--r-- | library/cpp/messagebus/message.h | 10 | ||||
-rw-r--r-- | library/cpp/messagebus/message_ptr_and_header.h | 4 | ||||
-rw-r--r-- | library/cpp/messagebus/network.cpp | 88 | ||||
-rw-r--r-- | library/cpp/messagebus/network_ut.cpp | 6 | ||||
-rw-r--r-- | library/cpp/monlib/service/monservice.cpp | 4 |
10 files changed, 123 insertions, 123 deletions
diff --git a/library/cpp/actors/core/event_pb_payload_ut.cpp b/library/cpp/actors/core/event_pb_payload_ut.cpp index 8f2f1ef369..eab007bc15 100644 --- a/library/cpp/actors/core/event_pb_payload_ut.cpp +++ b/library/cpp/actors/core/event_pb_payload_ut.cpp @@ -9,21 +9,21 @@ using namespace NActors; enum { EvMessageWithPayload = EventSpaceBegin(TEvents::ES_PRIVATE), EvArenaMessage, - EvArenaMessageBig, - EvMessageWithPayloadPreSerialized + EvArenaMessageBig, + EvMessageWithPayloadPreSerialized }; struct TEvMessageWithPayload : TEventPB<TEvMessageWithPayload, TMessageWithPayload, EvMessageWithPayload> { - TEvMessageWithPayload() = default; - explicit TEvMessageWithPayload(const TMessageWithPayload& p) - : TEventPB<TEvMessageWithPayload, TMessageWithPayload, EvMessageWithPayload>(p) - {} + TEvMessageWithPayload() = default; + explicit TEvMessageWithPayload(const TMessageWithPayload& p) + : TEventPB<TEvMessageWithPayload, TMessageWithPayload, EvMessageWithPayload>(p) + {} }; -struct TEvMessageWithPayloadPreSerialized : TEventPreSerializedPB<TEvMessageWithPayloadPreSerialized, TMessageWithPayload, EvMessageWithPayloadPreSerialized> { -}; - - +struct TEvMessageWithPayloadPreSerialized : TEventPreSerializedPB<TEvMessageWithPayloadPreSerialized, TMessageWithPayload, EvMessageWithPayloadPreSerialized> { +}; + + TRope MakeStringRope(const TString& message) { return message ? TRope(message) : TRope(); } @@ -113,42 +113,42 @@ Y_UNIT_TEST_SUITE(TEventProtoWithPayload) { TestSerializeDeserialize<TEvArenaMessage, TEvArenaMessageWithoutArena>(200, 14010); TestSerializeDeserialize<TEvArenaMessageWithoutArena, TEvArenaMessage>(2000, 4010); } - - Y_UNIT_TEST(PreSerializedCompatibility) { - // ensure TEventPreSerializedPB and TEventPB are interchangable with no compatibility issues - TMessageWithPayload msg; - msg.SetMeta("hello, world!"); - msg.AddPayloadId(123); - msg.AddPayloadId(999); - msg.AddSomeData("abc"); - msg.AddSomeData("xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"); - - TEvMessageWithPayloadPreSerialized e1; + + Y_UNIT_TEST(PreSerializedCompatibility) { + // ensure TEventPreSerializedPB and TEventPB are interchangable with no compatibility issues + TMessageWithPayload msg; + msg.SetMeta("hello, world!"); + msg.AddPayloadId(123); + msg.AddPayloadId(999); + msg.AddSomeData("abc"); + msg.AddSomeData("xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"); + + TEvMessageWithPayloadPreSerialized e1; Y_PROTOBUF_SUPPRESS_NODISCARD msg.SerializeToString(&e1.PreSerializedData); - - auto serializer1 = MakeHolder<TAllocChunkSerializer>(); + + auto serializer1 = MakeHolder<TAllocChunkSerializer>(); e1.SerializeToArcadiaStream(serializer1.Get()); - auto buffers1 = serializer1->Release(e1.IsExtendedFormat()); - UNIT_ASSERT_VALUES_EQUAL(buffers1->GetSize(), e1.CalculateSerializedSize()); - TString ser1 = buffers1->GetString(); - - TEvMessageWithPayload e2(msg); - auto serializer2 = MakeHolder<TAllocChunkSerializer>(); + auto buffers1 = serializer1->Release(e1.IsExtendedFormat()); + UNIT_ASSERT_VALUES_EQUAL(buffers1->GetSize(), e1.CalculateSerializedSize()); + TString ser1 = buffers1->GetString(); + + TEvMessageWithPayload e2(msg); + auto serializer2 = MakeHolder<TAllocChunkSerializer>(); e2.SerializeToArcadiaStream(serializer2.Get()); - auto buffers2 = serializer2->Release(e2.IsExtendedFormat()); - UNIT_ASSERT_VALUES_EQUAL(buffers2->GetSize(), e2.CalculateSerializedSize()); - TString ser2 = buffers2->GetString(); - UNIT_ASSERT_VALUES_EQUAL(ser1, ser2); - - // deserialize - auto data = MakeIntrusive<TEventSerializedData>(ser1, false); - THolder<TEvMessageWithPayloadPreSerialized> parsedEvent(static_cast<TEvMessageWithPayloadPreSerialized*>(TEvMessageWithPayloadPreSerialized::Load(data))); - UNIT_ASSERT_VALUES_EQUAL(parsedEvent->PreSerializedData, ""); // this field is empty after deserialization - auto& record = parsedEvent->GetRecord(); - UNIT_ASSERT_VALUES_EQUAL(record.GetMeta(), msg.GetMeta()); - UNIT_ASSERT_VALUES_EQUAL(record.PayloadIdSize(), msg.PayloadIdSize()); - UNIT_ASSERT_VALUES_EQUAL(record.PayloadIdSize(), 2); - UNIT_ASSERT_VALUES_EQUAL(record.GetPayloadId(0), msg.GetPayloadId(0)); - UNIT_ASSERT_VALUES_EQUAL(record.GetPayloadId(1), msg.GetPayloadId(1)); - } + auto buffers2 = serializer2->Release(e2.IsExtendedFormat()); + UNIT_ASSERT_VALUES_EQUAL(buffers2->GetSize(), e2.CalculateSerializedSize()); + TString ser2 = buffers2->GetString(); + UNIT_ASSERT_VALUES_EQUAL(ser1, ser2); + + // deserialize + auto data = MakeIntrusive<TEventSerializedData>(ser1, false); + THolder<TEvMessageWithPayloadPreSerialized> parsedEvent(static_cast<TEvMessageWithPayloadPreSerialized*>(TEvMessageWithPayloadPreSerialized::Load(data))); + UNIT_ASSERT_VALUES_EQUAL(parsedEvent->PreSerializedData, ""); // this field is empty after deserialization + auto& record = parsedEvent->GetRecord(); + UNIT_ASSERT_VALUES_EQUAL(record.GetMeta(), msg.GetMeta()); + UNIT_ASSERT_VALUES_EQUAL(record.PayloadIdSize(), msg.PayloadIdSize()); + UNIT_ASSERT_VALUES_EQUAL(record.PayloadIdSize(), 2); + UNIT_ASSERT_VALUES_EQUAL(record.GetPayloadId(0), msg.GetPayloadId(0)); + UNIT_ASSERT_VALUES_EQUAL(record.GetPayloadId(1), msg.GetPayloadId(1)); + } } diff --git a/library/cpp/grpc/client/grpc_client_low.h b/library/cpp/grpc/client/grpc_client_low.h index c831b1fa60..ab0a0627be 100644 --- a/library/cpp/grpc/client/grpc_client_low.h +++ b/library/cpp/grpc/client/grpc_client_low.h @@ -173,7 +173,7 @@ bool inline IsGRpcStatusGood(const TGrpcStatus& status) { return status.Ok(); } -// Response callback type - this callback will be called when request is finished +// Response callback type - this callback will be called when request is finished // (or after getting each chunk in case of streaming mode) template<typename TResponse> using TResponseCallback = std::function<void (TGrpcStatus&&, TResponse&&)>; @@ -236,8 +236,8 @@ public: using TPtr = TIntrusivePtr<TSimpleRequestProcessor>; using TAsyncRequest = TAsyncReaderPtr (TStub::*)(grpc::ClientContext*, const TRequest&, grpc::CompletionQueue*); - explicit TSimpleRequestProcessor(TResponseCallback<TResponse>&& callback) - : Callback_(std::move(callback)) + explicit TSimpleRequestProcessor(TResponseCallback<TResponse>&& callback) + : Callback_(std::move(callback)) { } ~TSimpleRequestProcessor() { @@ -316,8 +316,8 @@ public: using TPtr = TIntrusivePtr<TAdvancedRequestProcessor>; using TAsyncRequest = TAsyncReaderPtr (TStub::*)(grpc::ClientContext*, const TRequest&, grpc::CompletionQueue*); - explicit TAdvancedRequestProcessor(TAdvancedResponseCallback<TResponse>&& callback) - : Callback_(std::move(callback)) + explicit TAdvancedRequestProcessor(TAdvancedResponseCallback<TResponse>&& callback) + : Callback_(std::move(callback)) { } ~TAdvancedRequestProcessor() { @@ -1244,7 +1244,7 @@ public: */ template<typename TRequest, typename TResponse> void DoRequest(const TRequest& request, - TResponseCallback<TResponse> callback, + TResponseCallback<TResponse> callback, typename TSimpleRequestProcessor<TStub, TRequest, TResponse>::TAsyncRequest asyncRequest, const TCallMeta& metas = { }, IQueueClientContextProvider* provider = nullptr) @@ -1259,7 +1259,7 @@ public: */ template<typename TRequest, typename TResponse> void DoAdvancedRequest(const TRequest& request, - TAdvancedResponseCallback<TResponse> callback, + TAdvancedResponseCallback<TResponse> callback, typename TAdvancedRequestProcessor<TStub, TRequest, TResponse>::TAsyncRequest asyncRequest, const TCallMeta& metas = { }, IQueueClientContextProvider* provider = nullptr) diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 7cbd4494e8..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -136,12 +136,12 @@ public: }; static void* ListenSocketFunction(void* param) { - try { - ((TImpl*)param)->ListenSocket(); - } catch (...) { + try { + ((TImpl*)param)->ListenSocket(); + } catch (...) { + + } - } - return nullptr; } @@ -798,11 +798,11 @@ bool TRequestReplier::Reply(void* threadSpecificResource) { bool TryToBindAddresses(const THttpServerOptions& options, const std::function<void(TSocket)>* callbackOnBoundAddress) { THttpServerOptions::TBindAddresses addrs; - try { - options.BindAddresses(addrs); + try { + options.BindAddresses(addrs); } catch (const std::exception&) { return false; - } + } for (const auto& na : addrs) { for (TNetworkAddress::TIterator ai = na.Begin(); ai != na.End(); ++ai) { diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 79d1a4cb3b..3f0f50bc4c 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -6,7 +6,7 @@ #include <util/generic/hash.h> #include <util/generic/vector.h> #include <util/generic/deque.h> -#include <util/generic/utility.h> +#include <util/generic/utility.h> #include <util/generic/yexception.h> namespace NJson { @@ -205,7 +205,7 @@ namespace NJson { TArray* Array; TValueUnion() noexcept { - Zero(*this); + Zero(*this); } ~TValueUnion() noexcept { } diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index ecfa97e4c3..a61ee9ce22 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -1798,7 +1798,7 @@ class TLogSources { private: TTraceCleaner& Cleaner; TInstant Now; - using TLogSourcePtr = std::unique_ptr<ILogSource>; + using TLogSourcePtr = std::unique_ptr<ILogSource>; TMap<TString, TLogSourcePtr> LogSources; public: explicit TLogSources(TTraceCleaner& cleaner, TInstant now = TInstant::Now()) @@ -1809,20 +1809,20 @@ public: void Push(const TString& sid, const TAtomicSharedPtr<NLWTrace::TLogPb>& log) { TLogSourcePtr ls(new TSnapshotLogSource(sid, log)); - LogSources.emplace(ls->GetId(), std::move(ls)); + LogSources.emplace(ls->GetId(), std::move(ls)); } void Push(const TString& id, const NLWTrace::TSession* trace) { TLogSourcePtr ls(new TTraceLogSource(id, trace, Cleaner)); - LogSources.emplace(ls->GetId(), std::move(ls)); + LogSources.emplace(ls->GetId(), std::move(ls)); } template <class TFunc> void ForEach(TFunc& func) { for (auto& kv : LogSources) { - func.Push(kv.second.get()); + func.Push(kv.second.get()); } } @@ -1830,7 +1830,7 @@ public: void ForEach(TFunc& func) const { for (const auto& kv : LogSources) { - func.Push(kv.second.get()); + func.Push(kv.second.get()); } } }; diff --git a/library/cpp/messagebus/message.h b/library/cpp/messagebus/message.h index 0fc1a1b707..005ca10c65 100644 --- a/library/cpp/messagebus/message.h +++ b/library/cpp/messagebus/message.h @@ -120,11 +120,11 @@ namespace NBus { struct TBusHeader { friend class TBusMessage; - TBusKey Id = 0; ///< unique message ID - ui32 Size = 0; ///< total size of the message - TBusInstant SendTime = 0; ///< time the message was sent - ui16 FlagsInternal = 0; ///< TRACE is one of the flags - ui16 Type = 0; ///< to be used by TBusProtocol + TBusKey Id = 0; ///< unique message ID + ui32 Size = 0; ///< total size of the message + TBusInstant SendTime = 0; ///< time the message was sent + ui16 FlagsInternal = 0; ///< TRACE is one of the flags + ui16 Type = 0; ///< to be used by TBusProtocol int GetVersionInternal() { return (FlagsInternal & MESSAGE_VERSION_INTERNAL) >> 4; diff --git a/library/cpp/messagebus/message_ptr_and_header.h b/library/cpp/messagebus/message_ptr_and_header.h index c4364f690f..9b4e2fd270 100644 --- a/library/cpp/messagebus/message_ptr_and_header.h +++ b/library/cpp/messagebus/message_ptr_and_header.h @@ -18,8 +18,8 @@ namespace NBus { { } - explicit TBusMessagePtrAndHeader(TBusMessage* messagePtr) - : MessagePtr(messagePtr) + explicit TBusMessagePtrAndHeader(TBusMessage* messagePtr) + : MessagePtr(messagePtr) , Header(*MessagePtr->GetHeader()) , LocalFlags(MessagePtr->LocalFlags) { diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp index 1e2a89d605..304bedae5a 100644 --- a/library/cpp/messagebus/network.cpp +++ b/library/cpp/messagebus/network.cpp @@ -14,15 +14,15 @@ namespace { Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); SOCKET fd = ::socket(af, SOCK_STREAM, 0); - if (fd == INVALID_SOCKET) { - ythrow TSystemError() << "failed to create a socket"; - } + if (fd == INVALID_SOCKET) { + ythrow TSystemError() << "failed to create a socket"; + } int one = 1; int r1 = SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, one); - if (r1 < 0) { - ythrow TSystemError() << "failed to setsockopt SO_REUSEADDR"; - } + if (r1 < 0) { + ythrow TSystemError() << "failed to setsockopt SO_REUSEADDR"; + } #ifdef SO_REUSEPORT if (reusePort) { @@ -54,72 +54,72 @@ namespace { int r2 = ::bind(fd, sa, len); if (r2 < 0) { - ythrow TSystemError() << "failed to bind on port " << port; + ythrow TSystemError() << "failed to bind on port " << port; } int rsn = ::getsockname(fd, addr->MutableAddr(), addr->LenPtr()); - if (rsn < 0) { - ythrow TSystemError() << "failed to getsockname"; - } + if (rsn < 0) { + ythrow TSystemError() << "failed to getsockname"; + } int r3 = ::listen(fd, 50); - if (r3 < 0) { - ythrow TSystemError() << "listen failed"; - } + if (r3 < 0) { + ythrow TSystemError() << "listen failed"; + } TBindResult r; r.Socket.Reset(new TSocketHolder(fd)); r.Addr = TNetAddr(addr.Release()); return r; } - + TMaybe<TBindResult> TryBindOnPortProto(int port, int af, bool reusePort) { - try { + try { return {BindOnPortProto(port, af, reusePort)}; - } catch (const TSystemError&) { - return {}; - } - } - - std::pair<unsigned, TVector<TBindResult>> AggregateBindResults(TBindResult&& r1, TBindResult&& r2) { - Y_VERIFY(r1.Addr.GetPort() == r2.Addr.GetPort(), "internal"); - std::pair<unsigned, TVector<TBindResult>> r; - r.second.reserve(2); - - r.first = r1.Addr.GetPort(); - r.second.emplace_back(std::move(r1)); - r.second.emplace_back(std::move(r2)); - return r; - } + } catch (const TSystemError&) { + return {}; + } + } + + std::pair<unsigned, TVector<TBindResult>> AggregateBindResults(TBindResult&& r1, TBindResult&& r2) { + Y_VERIFY(r1.Addr.GetPort() == r2.Addr.GetPort(), "internal"); + std::pair<unsigned, TVector<TBindResult>> r; + r.second.reserve(2); + + r.first = r1.Addr.GetPort(); + r.second.emplace_back(std::move(r1)); + r.second.emplace_back(std::move(r2)); + return r; + } } std::pair<unsigned, TVector<TBindResult>> NBus::BindOnPort(int port, bool reusePort) { std::pair<unsigned, TVector<TBindResult>> r; - r.second.reserve(2); + r.second.reserve(2); if (port != 0) { return AggregateBindResults(BindOnPortProto(port, AF_INET, reusePort), BindOnPortProto(port, AF_INET6, reusePort)); - } - - // use nothrow versions in cycle - for (int i = 0; i < 1000; ++i) { + } + + // use nothrow versions in cycle + for (int i = 0; i < 1000; ++i) { TMaybe<TBindResult> in4 = TryBindOnPortProto(0, AF_INET, reusePort); - if (!in4) { - continue; + if (!in4) { + continue; } - + TMaybe<TBindResult> in6 = TryBindOnPortProto(in4->Addr.GetPort(), AF_INET6, reusePort); - if (!in6) { - continue; + if (!in6) { + continue; } - - return AggregateBindResults(std::move(*in4), std::move(*in6)); + + return AggregateBindResults(std::move(*in4), std::move(*in6)); } - + TBindResult in4 = BindOnPortProto(0, AF_INET, reusePort); TBindResult in6 = BindOnPortProto(in4.Addr.GetPort(), AF_INET6, reusePort); - return AggregateBindResults(std::move(in4), std::move(in6)); + return AggregateBindResults(std::move(in4), std::move(in6)); } void NBus::NPrivate::SetSockOptTcpCork(SOCKET s, bool value) { diff --git a/library/cpp/messagebus/network_ut.cpp b/library/cpp/messagebus/network_ut.cpp index f919286e8d..f1798419db 100644 --- a/library/cpp/messagebus/network_ut.cpp +++ b/library/cpp/messagebus/network_ut.cpp @@ -56,10 +56,10 @@ Y_UNIT_TEST_SUITE(Network) { UNIT_ASSERT_VALUES_EQUAL(r.at(0).Addr.GetPort(), r.at(1).Addr.GetPort()); } - + Y_UNIT_TEST(BindOnBusyPort) { auto r = BindOnPort(0, false); - + UNIT_ASSERT_EXCEPTION_CONTAINS(BindOnPort(r.first, false), TSystemError, "failed to bind on port " + ToString(r.first)); - } + } } diff --git a/library/cpp/monlib/service/monservice.cpp b/library/cpp/monlib/service/monservice.cpp index 67b133365e..d1b9cda1d2 100644 --- a/library/cpp/monlib/service/monservice.cpp +++ b/library/cpp/monlib/service/monservice.cpp @@ -16,9 +16,9 @@ TMonService2::TMonService2(ui16 port, const TString& host, ui32 threads, const T : TMonService2(HttpServerOptions(port, host, threads), title, std::move(auth)) { } - + TMonService2::TMonService2(const THttpServerOptions& options, const TString& title, THolder<IAuthProvider> auth) - : NMonitoring::TMtHttpServer(options, std::bind(&TMonService2::ServeRequest, this, std::placeholders::_1, std::placeholders::_2)) + : NMonitoring::TMtHttpServer(options, std::bind(&TMonService2::ServeRequest, this, std::placeholders::_1, std::placeholders::_2)) , Title(title) , IndexMonPage(new TIndexMonPage("", Title)) , AuthProvider_{std::move(auth)} |