diff options
author | feldsherov <feldsherov@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
commit | e73723ec73b27276cd45b9b46b752138a51d669c (patch) | |
tree | 055f8efa1a290665c7be6bb571131e050cd9517a | |
parent | 4d75b7f76712a8150bd526a7ef43d279d9892eb7 (diff) | |
download | ydb-e73723ec73b27276cd45b9b46b752138a51d669c.tar.gz |
Restoring authorship annotation for <feldsherov@yandex-team.ru>. Commit 1 of 2.
23 files changed, 271 insertions, 271 deletions
diff --git a/build/config/tests/clang_tidy/config.yaml b/build/config/tests/clang_tidy/config.yaml index d55707592c..a2645aeeec 100644 --- a/build/config/tests/clang_tidy/config.yaml +++ b/build/config/tests/clang_tidy/config.yaml @@ -3,7 +3,7 @@ Checks: > arcadia-typeid-name-restriction, bugprone-use-after-move, readability-identifier-naming, -CheckOptions: +CheckOptions: - key: readability-identifier-naming.ClassCase value: CamelCase - key: readability-identifier-naming.PublicMemberCase diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 6c753f68a9..21b63213b6 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -24,7 +24,7 @@ RECURSE( mapped_file/ut mbitmap omni - text_norm + text_norm omni/print_omni omni/usage omni/ut diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 6689be684f..71f4b9f927 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -436,10 +436,10 @@ TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) c ); } -TString THttpInput::BestCompressionScheme() const { +TString THttpInput::BestCompressionScheme() const { return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs()); -} - +} + bool THttpInput::GetContentLength(ui64& value) const noexcept { return Impl_->GetContentLength(value); } diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 1ea35df675..deabe5de45 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -441,52 +441,52 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(!result.Contains("content-length")); } - Y_UNIT_TEST(CodecsPriority) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + Y_UNIT_TEST(CodecsPriority) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"br", "gzip"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: br")); - } - - Y_UNIT_TEST(CodecsPriority2) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: br")); + } + + Y_UNIT_TEST(CodecsPriority2) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"gzip", "br"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: gzip")); - } - + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: gzip")); + } + Y_UNIT_TEST(HasTrailers) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index 38a76c4c30..eee1e95a5f 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -26,14 +26,14 @@ public: return &HO_; } - inline void Reset() { - if (S_ != INVALID_SOCKET) { - // send RST packet to client - S_.SetLinger(true, 0); - S_.Close(); - } - } - + inline void Reset() { + if (S_ != INVALID_SOCKET) { + // send RST packet to client + S_.SetLinger(true, 0); + S_.Close(); + } + } + private: TSocket S_; TSocketInput SI_; @@ -63,7 +63,7 @@ THttpInput* THttpServerConn::Input() noexcept { THttpOutput* THttpServerConn::Output() noexcept { return Impl_->Output(); } - -void THttpServerConn::Reset() { - return Impl_->Reset(); -} + +void THttpServerConn::Reset() { + return Impl_->Reset(); +} diff --git a/library/cpp/http/server/conn.h b/library/cpp/http/server/conn.h index 3aa5329af4..181bc3fc5c 100644 --- a/library/cpp/http/server/conn.h +++ b/library/cpp/http/server/conn.h @@ -29,8 +29,8 @@ public: return Output()->CanBeKeepAlive(); } - void Reset(); - + void Reset(); + private: class TImpl; THolder<TImpl> Impl_; diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd7..00ca18e1cb 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -668,14 +668,14 @@ void TClientRequest::ReleaseConnection() { } } -void TClientRequest::ResetConnection() { - if (HttpConn_) { - // send RST packet to client - HttpConn_->Reset(); - HttpConn_.Destroy(); - } -} - +void TClientRequest::ResetConnection() { + if (HttpConn_) { + // send RST packet to client + HttpConn_->Reset(); + HttpConn_.Destroy(); + } +} + void TClientRequest::Process(void* ThreadSpecificResource) { THolder<TClientRequest> this_(this); diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..1328bdce3f 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -128,8 +128,8 @@ public: void ReleaseConnection(); - void ResetConnection(); - + void ResetConnection(); + private: /* * Processes the request after 'connection' been created and 'Headers' been read diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index cc62bb988e..16f72df972 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -481,29 +481,29 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { ExceptionMessage = CurrentExceptionMessage(); } - TString ExceptionMessage; - }; - - class TResetConnectionServer: public THttpServer::ICallBack { - class TRequest: public TClientRequest { - public: - bool Reply(void* /*tsr*/) override { - Output() << "HTTP/1.1"; - ResetConnection(); - - return true; - } - }; - + TString ExceptionMessage; + }; + + class TResetConnectionServer: public THttpServer::ICallBack { + class TRequest: public TClientRequest { + public: + bool Reply(void* /*tsr*/) override { + Output() << "HTTP/1.1"; + ResetConnection(); + + return true; + } + }; + public: - TClientRequest* CreateClient() override { - return new TRequest(); - } - - void OnException() override { - ExceptionMessage = CurrentExceptionMessage(); - } - + TClientRequest* CreateClient() override { + return new TRequest(); + } + + void OnException() override { + ExceptionMessage = CurrentExceptionMessage(); + } + TString ExceptionMessage; }; @@ -526,21 +526,21 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } }; - Y_UNIT_TEST(TTestResetConnection) { - TPortManager pm; - const ui16 port = pm.GetPort(); - - TResetConnectionServer serverImpl; - THttpServer server(&serverImpl, THttpServer::TOptions(port)); - UNIT_ASSERT(server.Start()); - - TTestRequest r(port, "request"); - - UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); - - server.Stop(); - }; - + Y_UNIT_TEST(TTestResetConnection) { + TPortManager pm; + const ui16 port = pm.GetPort(); + + TResetConnectionServer serverImpl; + THttpServer server(&serverImpl, THttpServer::TOptions(port)); + UNIT_ASSERT(server.Start()); + + TTestRequest r(port, "request"); + + UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); + + server.Stop(); + }; + Y_UNIT_TEST(TTestReleaseConnection) { TPortManager pm; const ui16 port = pm.GetPort(); diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h index 4c33498dfa..7b30e98dc1 100644 --- a/library/cpp/protobuf/json/json2proto.h +++ b/library/cpp/protobuf/json/json2proto.h @@ -98,11 +98,11 @@ namespace NProtobufJson { return *this; } - TSelf& SetAllowUnknownFields(bool value) { - AllowUnknownFields = value; - return *this; - } - + TSelf& SetAllowUnknownFields(bool value) { + AllowUnknownFields = value; + return *this; + } + FldNameMode FieldNameMode = FieldNameOriginalCase; bool AllowUnknownFields = true; diff --git a/library/cpp/tvmauth/client/client_status.h b/library/cpp/tvmauth/client/client_status.h index bbaf29d289..8805d471c8 100644 --- a/library/cpp/tvmauth/client/client_status.h +++ b/library/cpp/tvmauth/client/client_status.h @@ -10,7 +10,7 @@ namespace NTvmAuth { Ok, Warning, Error, - IncompleteTicketsSet, + IncompleteTicketsSet, }; TClientStatus(ECode state, TString&& lastError) @@ -35,23 +35,23 @@ namespace NTvmAuth { } TString CreateJugglerMessage() const { - return TStringBuilder() << GetJugglerCode() << ";TvmClient: " << LastError_ << "\n"; + return TStringBuilder() << GetJugglerCode() << ";TvmClient: " << LastError_ << "\n"; } private: - int32_t GetJugglerCode() const { - switch (Code_) { - case ECode::Ok: + int32_t GetJugglerCode() const { + switch (Code_) { + case ECode::Ok: return 0; // OK juggler check state - case ECode::Warning: - case ECode::IncompleteTicketsSet: + case ECode::Warning: + case ECode::IncompleteTicketsSet: return 1; // WARN juggler check state - case ECode::Error: + case ECode::Error: return 2; // CRIT juggler check state - } - return 2; // This should not happen, so set check state as CRIT. - } - + } + return 2; // This should not happen, so set check state as CRIT. + } + ECode Code_ = Ok; TString LastError_; }; diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp index 6ec15c0e88..f441cc3c35 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp @@ -53,10 +53,10 @@ namespace NTvmAuth::NDynamicClient { { } - TTvmClient::~TTvmClient() { - TBase::StopWorker(); - } - + TTvmClient::~TTvmClient() { + TBase::StopWorker(); + } + void TTvmClient::Worker() { TBase::Worker(); ProcessTasks(); diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h index 58ed953b63..ed9ba237a5 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h @@ -30,7 +30,7 @@ namespace NTvmAuth::NDynamicClient { class TTvmClient: public NTvmApi::TThreadedUpdater { public: static TAsyncUpdaterPtr Create(const NTvmApi::TClientSettings& settings, TLoggerPtr logger); - virtual ~TTvmClient(); + virtual ~TTvmClient(); NThreading::TFuture<TAddResponse> Add(TDsts&& dsts); std::optional<TString> GetOptionalServiceTicketFor(const TTvmId dst); diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp b/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp index 89403c15e4..cd20efc4d9 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(DynamicClient) { mutable std::vector<TString> Tickets; }; - Y_UNIT_TEST(StartWithIncompleteTicketsSet) { + Y_UNIT_TEST(StartWithIncompleteTicketsSet) { TInstant now = TInstant::Now(); CleanCache(); WriteFile("./service_tickets", @@ -96,12 +96,12 @@ Y_UNIT_TEST_SUITE(DynamicClient) { NTvmApi::TClientSettings s; s.SetSelfTvmId(100500); - s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}, false); - s.SetDiskCacheDir(CACHE_DIR); - - auto l = MakeIntrusive<TLogger>(); - - { + s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}, false); + s.SetDiskCacheDir(CACHE_DIR); + + auto l = MakeIntrusive<TLogger>(); + + { TOfflineUpdater client(s, l, false, @@ -109,51 +109,51 @@ Y_UNIT_TEST_SUITE(DynamicClient) { R"({"213" : { "error" : "some error"}})", R"({"123" : { "ticket" : "service_ticket_3"}})", }); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(19)); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(19)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); - - NThreading::TFuture<TAddResponse> fut = client.Add({123}); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - - client.Worker(); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - + + NThreading::TFuture<TAddResponse> fut = client.Add({123}); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + + client.Worker(); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(19)); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(123)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(19)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(123)); - - UNIT_ASSERT(fut.HasValue()); - TAddResponse resp{ - {123, {EDstStatus::Success, ""}}, - }; - UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); - + + UNIT_ASSERT(fut.HasValue()); + TAddResponse resp{ + {123, {EDstStatus::Success, ""}}, + }; + UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); + UNIT_ASSERT(client.Tickets.empty()); - - TDsts dsts{19, 123, 213}; - UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); - - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - } - } - - Y_UNIT_TEST(StartWithEmptyTicketsSet) { + + TDsts dsts{19, 123, 213}; + UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); + + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + } + } + + Y_UNIT_TEST(StartWithEmptyTicketsSet) { CleanCache(); - - NTvmApi::TClientSettings s; - s.SetSelfTvmId(100500); - s.EnableServiceTicketsFetchOptions("qwerty", {{"kolmo", 213}}, false); - s.SetDiskCacheDir(CACHE_DIR); - - auto l = MakeIntrusive<TLogger>(); - - { + + NTvmApi::TClientSettings s; + s.SetSelfTvmId(100500); + s.EnableServiceTicketsFetchOptions("qwerty", {{"kolmo", 213}}, false); + s.SetDiskCacheDir(CACHE_DIR); + + auto l = MakeIntrusive<TLogger>(); + + { TOfflineUpdater client(s, l, false, @@ -161,46 +161,46 @@ Y_UNIT_TEST_SUITE(DynamicClient) { R"({"213" : { "error" : "some error"}})", R"({"123" : { "ticket" : "3:serv:CBAQ__________9_IgYIlJEGEHs:CcafYQH-FF5XaXMuJrgLZj98bIC54cs1ZkcFS9VV_9YM9iOM_0PXCtMkdg85rFjxE_BMpg7bE8ZuoqNfdw0FPt0BAKNeISwlydj4o0IjY82--LZBpP8CRn-EpAnkRaDShdlfrcF2pk1SSmEX8xdyZVQEnkUPY0cHGlFnu231vnE"}})", }); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - - NThreading::TFuture<TAddResponse> fut = client.Add({123}); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - - client.Worker(); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + + NThreading::TFuture<TAddResponse> fut = client.Add({123}); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + + client.Worker(); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(123)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(123)); - - UNIT_ASSERT(fut.HasValue()); - TAddResponse resp{ - {123, {EDstStatus::Success, ""}}, - }; - UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); - + + UNIT_ASSERT(fut.HasValue()); + TAddResponse resp{ + {123, {EDstStatus::Success, ""}}, + }; + UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); + UNIT_ASSERT(client.Tickets.empty()); - - TDsts dsts{123, 213}; - UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); - - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - } - }; - Y_UNIT_TEST(StartWithIncompleteCacheAndAdd) { - TInstant now = TInstant::Now(); + + TDsts dsts{123, 213}; + UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); + + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + } + }; + Y_UNIT_TEST(StartWithIncompleteCacheAndAdd) { + TInstant now = TInstant::Now(); CleanCache(); WriteFile("./service_tickets", - R"({"19" : { "ticket" : "3:serv:CBAQ__________9_IgYIKhCUkQY:CX"}})" - "\t100500", - now); - - NTvmApi::TClientSettings s; - s.SetSelfTvmId(100500); + R"({"19" : { "ticket" : "3:serv:CBAQ__________9_IgYIKhCUkQY:CX"}})" + "\t100500", + now); + + NTvmApi::TClientSettings s; + s.SetSelfTvmId(100500); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}); s.SetDiskCacheDir(CACHE_DIR); diff --git a/library/cpp/tvmauth/client/misc/api/settings.h b/library/cpp/tvmauth/client/misc/api/settings.h index 715ab3e02c..f0050b65e7 100644 --- a/library/cpp/tvmauth/client/misc/api/settings.h +++ b/library/cpp/tvmauth/client/misc/api/settings.h @@ -163,9 +163,9 @@ namespace NTvmAuth::NTvmApi { } // Deprecated: set attributes directly - void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, - TDstMap&& dsts, - const bool considerIncompleteTicketsSetAsError = true) { + void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, + TDstMap&& dsts, + const bool considerIncompleteTicketsSetAsError = true) { IsIncompleteTicketsSetAnError = considerIncompleteTicketsSetAsError; Secret = selfSecret; @@ -179,9 +179,9 @@ namespace NTvmAuth::NTvmApi { } // Deprecated: set attributes directly - void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, - TDstVector&& dsts, - const bool considerIncompleteTicketsSetAsError = true) { + void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, + TDstVector&& dsts, + const bool considerIncompleteTicketsSetAsError = true) { IsIncompleteTicketsSetAnError = considerIncompleteTicketsSetAsError; Secret = selfSecret; FetchServiceTicketsForDsts = std::move(dsts); diff --git a/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp b/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp index a7df49c05d..3b691042cd 100644 --- a/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp +++ b/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp @@ -50,7 +50,7 @@ namespace NTvmAuth::NTvmApi { TClientStatus TThreadedUpdater::GetStatus() const { const TClientStatus::ECode state = GetState(); - return TClientStatus(state, GetLastError(state == TClientStatus::Ok || state == TClientStatus::IncompleteTicketsSet)); + return TClientStatus(state, GetLastError(state == TClientStatus::Ok || state == TClientStatus::IncompleteTicketsSet)); } NRoles::TRolesPtr TThreadedUpdater::GetRoles() const { @@ -72,10 +72,10 @@ namespace NTvmAuth::NTvmApi { } if (tickets->TicketsById.size() < Destinations_.size()) { if (Settings_.IsIncompleteTicketsSetAnError) { - return TClientStatus::Error; - } else { - return TClientStatus::IncompleteTicketsSet; - } + return TClientStatus::Error; + } else { + return TClientStatus::IncompleteTicketsSet; + } } } if ((Settings_.IsServiceTicketCheckingRequired() || Settings_.IsUserTicketCheckingRequired()) && ArePublicKeysInvalid(now)) { @@ -375,9 +375,9 @@ namespace NTvmAuth::NTvmApi { SetUpdateTimeOfServiceTickets(time); - if (count > 0) { - LogInfo(TStringBuilder() << "Cache was updated with " << count << " service ticket(s): " << time); - } + if (count > 0) { + LogInfo(TStringBuilder() << "Cache was updated with " << count << " service ticket(s): " << time); + } } void TThreadedUpdater::UpdatePublicKeysCache(const TString& publicKeys, TInstant time) { diff --git a/library/cpp/tvmauth/client/misc/async_updater.cpp b/library/cpp/tvmauth/client/misc/async_updater.cpp index 9cb0332ed4..a8adef3d1f 100644 --- a/library/cpp/tvmauth/client/misc/async_updater.cpp +++ b/library/cpp/tvmauth/client/misc/async_updater.cpp @@ -49,8 +49,8 @@ namespace NTvmAuth { } bool TAsyncUpdaterBase::AreServiceTicketsInvalid(TInstant now) const { - TServiceTicketsPtr c = GetCachedServiceTickets(); - // Empty set of tickets is allways valid. + TServiceTicketsPtr c = GetCachedServiceTickets(); + // Empty set of tickets is allways valid. return c && !c->TicketsById.empty() && IsInvalid(GetInvalidationTimeOfServiceTickets(), now); } diff --git a/library/cpp/tvmauth/client/misc/async_updater.h b/library/cpp/tvmauth/client/misc/async_updater.h index 7b556d7a38..1ff0b4f4e7 100644 --- a/library/cpp/tvmauth/client/misc/async_updater.h +++ b/library/cpp/tvmauth/client/misc/async_updater.h @@ -29,15 +29,15 @@ namespace NTvmAuth { public: using TMapAliasStr = THashMap<TClientSettings::TAlias, TString>; using TMapIdStr = THashMap<TTvmId, TString>; - using TIdSet = THashSet<TTvmId>; - using TAliasSet = THashSet<TClientSettings::TAlias>; + using TIdSet = THashSet<TTvmId>; + using TAliasSet = THashSet<TClientSettings::TAlias>; using TMapAliasId = THashMap<TClientSettings::TAlias, TTvmId>; TServiceTickets(TMapIdStr&& tickets, TMapIdStr&& errors, const TMapAliasId& dstMap) : TicketsById(std::move(tickets)) , ErrorsById(std::move(errors)) { - InitAliasesAndUnfetchedIds(dstMap); + InitAliasesAndUnfetchedIds(dstMap); InitInvalidationTime(); } @@ -66,7 +66,7 @@ namespace NTvmAuth { TAliasSet UnfetchedAliases; private: - void InitAliasesAndUnfetchedIds(const TMapAliasId& dstMap) { + void InitAliasesAndUnfetchedIds(const TMapAliasId& dstMap) { for (const auto& pair : dstMap) { auto it = TicketsById.find(pair.second); auto errIt = ErrorsById.find(pair.second); @@ -74,11 +74,11 @@ namespace NTvmAuth { if (it == TicketsById.end()) { if (errIt != ErrorsById.end()) { Y_ENSURE(ErrorsByAlias.insert({pair.first, errIt->second}).second, - "failed to add: " << pair.first); - } else { + "failed to add: " << pair.first); + } else { UnfetchedAliases.insert(pair.first); UnfetchedIds.insert(pair.second); - } + } } else { Y_ENSURE(TicketsByAlias.insert({pair.first, it->second}).second, "failed to add: " << pair.first); diff --git a/library/cpp/tvmauth/client/misc/getter.h b/library/cpp/tvmauth/client/misc/getter.h index b0327d69e9..3f627dd4d4 100644 --- a/library/cpp/tvmauth/client/misc/getter.h +++ b/library/cpp/tvmauth/client/misc/getter.h @@ -28,8 +28,8 @@ namespace NTvmAuth { } private: - template <class Key, class Cont, class UnfetchedCont> - TString GetTicketImpl(const Key& dst, const Cont& tickets, const Cont& errors, const UnfetchedCont& unfetched) const { + template <class Key, class Cont, class UnfetchedCont> + TString GetTicketImpl(const Key& dst, const Cont& tickets, const Cont& errors, const UnfetchedCont& unfetched) const { auto it = tickets.find(dst); if (it != tickets.end()) { return it->second; @@ -42,11 +42,11 @@ namespace NTvmAuth { << it->second; } - if (unfetched.contains(dst)) { - ythrow TMissingServiceTicket() - << "Failed to get ticket for '" << dst << "': this dst was not fetched yet."; - } - + if (unfetched.contains(dst)) { + ythrow TMissingServiceTicket() + << "Failed to get ticket for '" << dst << "': this dst was not fetched yet."; + } + ythrow TBrokenTvmClientSettings() << "Destination '" << dst << "' was not specified in settings. " << "Check your settings (if you use Qloud/YP/tvmtool - check it's settings)"; diff --git a/library/cpp/tvmauth/client/ut/async_updater_ut.cpp b/library/cpp/tvmauth/client/ut/async_updater_ut.cpp index 1c1e8cbaae..0252ffcfc8 100644 --- a/library/cpp/tvmauth/client/ut/async_updater_ut.cpp +++ b/library/cpp/tvmauth/client/ut/async_updater_ut.cpp @@ -83,9 +83,9 @@ Y_UNIT_TEST_SUITE(AsyncUpdater) { Y_UNIT_TEST(ServiceTickets_Aliases) { using TId = TServiceTickets::TMapIdStr; - using TUnfetchedId = TServiceTickets::TIdSet; + using TUnfetchedId = TServiceTickets::TIdSet; using TStr = TServiceTickets::TMapAliasStr; - using TUnfetchedAlias = TServiceTickets::TAliasSet; + using TUnfetchedAlias = TServiceTickets::TAliasSet; using TAls = TServiceTickets::TMapAliasId; TServiceTickets t(TId{}, TId{}, TAls{}); @@ -106,14 +106,14 @@ Y_UNIT_TEST_SUITE(AsyncUpdater) { UNIT_ASSERT_EQUAL(TStr({{"1", "t1"}, {"2", "t2"}}), t.TicketsByAlias); UNIT_ASSERT_EQUAL(TStr({{"3", "e1"}}), t.ErrorsByAlias); UNIT_ASSERT_EQUAL(TUnfetchedAlias({}), t.UnfetchedAliases); - } - - Y_UNIT_TEST(ServiceTickets_UnfetchedIds) { - using TId = TServiceTickets::TMapIdStr; - using TUnfetchedId = TServiceTickets::TIdSet; - using TStr = TServiceTickets::TMapAliasStr; - using TUnfetchedAlias = TServiceTickets::TAliasSet; - using TAls = TServiceTickets::TMapAliasId; + } + + Y_UNIT_TEST(ServiceTickets_UnfetchedIds) { + using TId = TServiceTickets::TMapIdStr; + using TUnfetchedId = TServiceTickets::TIdSet; + using TStr = TServiceTickets::TMapAliasStr; + using TUnfetchedAlias = TServiceTickets::TAliasSet; + using TAls = TServiceTickets::TMapAliasId; TServiceTickets t(TId({{1, "t1"}, {2, "t2"}}), TId(), TAls({{"1", 1}, {"2", 2}, {"3", 3}})); diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e804346..3c3b303307 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -601,10 +601,10 @@ public: return Ops_->SendV(Fd_, parts, count); } - inline void Close() { - Fd_.Close(); - } - + inline void Close() { + Fd_.Close(); + } + private: TSocketHolder Fd_; TOps* Ops_; @@ -884,10 +884,10 @@ ssize_t TSocket::SendV(const TPart* parts, size_t count) { return Impl_->SendV(parts, count); } -void TSocket::Close() { - Impl_->Close(); -} - +void TSocket::Close() { + Impl_->Close(); +} + TSocketInput::TSocketInput(const TSocket& s) noexcept : S_(s) { diff --git a/util/network/socket.h b/util/network/socket.h index 40c8648b40..44d1097d93 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -367,8 +367,8 @@ public: ::ShutDown(Fd(), mode); } - void Close(); - + void Close(); + ssize_t Send(const void* data, size_t len); ssize_t Recv(void* buf, size_t len); diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 6b20e11f70..d7f6123322 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -24,7 +24,7 @@ class TSockTest: public TTestBase { UNIT_TEST(TestNetworkResolutionError); UNIT_TEST(TestNetworkResolutionErrorMessage); UNIT_TEST(TestBrokenPipe); - UNIT_TEST(TestClose); + UNIT_TEST(TestClose); UNIT_TEST(TestReusePortAvailCheck); UNIT_TEST_SUITE_END(); @@ -35,7 +35,7 @@ public: void TestNetworkResolutionError(); void TestNetworkResolutionErrorMessage(); void TestBrokenPipe(); - void TestClose(); + void TestClose(); void TestReusePortAvailCheck(); }; @@ -166,25 +166,25 @@ void TSockTest::TestBrokenPipe() { UNIT_ASSERT(sent < 0); } -void TSockTest::TestClose() { - SOCKET socks[2]; - +void TSockTest::TestClose() { + SOCKET socks[2]; + UNIT_ASSERT_EQUAL(SocketPair(socks), 0); - TSocket receiver(socks[1]); - - UNIT_ASSERT_EQUAL(static_cast<SOCKET>(receiver), socks[1]); - -#if defined _linux_ - UNIT_ASSERT_GE(fcntl(socks[1], F_GETFD), 0); - receiver.Close(); - UNIT_ASSERT_EQUAL(fcntl(socks[1], F_GETFD), -1); -#else - receiver.Close(); -#endif - - UNIT_ASSERT_EQUAL(static_cast<SOCKET>(receiver), INVALID_SOCKET); -} - + TSocket receiver(socks[1]); + + UNIT_ASSERT_EQUAL(static_cast<SOCKET>(receiver), socks[1]); + +#if defined _linux_ + UNIT_ASSERT_GE(fcntl(socks[1], F_GETFD), 0); + receiver.Close(); + UNIT_ASSERT_EQUAL(fcntl(socks[1], F_GETFD), -1); +#else + receiver.Close(); +#endif + + UNIT_ASSERT_EQUAL(static_cast<SOCKET>(receiver), INVALID_SOCKET); +} + void TSockTest::TestReusePortAvailCheck() { #if defined _linux_ utsname sysInfo; |