diff options
author | elantsev <elantsev@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
commit | 095c2e55a230f89487c2f2caace05e108742d72c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | afa1b6e6f8b6ee9f8df080d41bcb19b95c25c261 (diff) | |
download | ydb-095c2e55a230f89487c2f2caace05e108742d72c.tar.gz |
Restoring authorship annotation for <elantsev@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/coroutine/engine/impl.h | 8 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/poller.cpp | 10 | ||||
-rw-r--r-- | library/cpp/coroutine/listener/listen.cpp | 18 | ||||
-rw-r--r-- | library/cpp/coroutine/listener/listen.h | 28 | ||||
-rw-r--r-- | library/cpp/http/io/stream.cpp | 4 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 80 | ||||
-rw-r--r-- | util/datetime/parser_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/intrlist.h | 24 | ||||
-rw-r--r-- | util/generic/intrlist_ut.cpp | 344 | ||||
-rw-r--r-- | util/network/socket.cpp | 76 | ||||
-rw-r--r-- | util/network/socket.h | 2 | ||||
-rw-r--r-- | util/stream/format.h | 4 | ||||
-rw-r--r-- | util/system/context.cpp | 4 | ||||
-rw-r--r-- | util/system/fasttime.cpp | 6 |
14 files changed, 305 insertions, 305 deletions
diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index 715454d695..283a96ecf1 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -92,9 +92,9 @@ public: } bool Scheduled() const noexcept { - return Scheduled_; - } - + return Scheduled_; + } + bool Join(TCont* c, TInstant deadLine = TInstant::Max()) noexcept; void ReSchedule() noexcept; @@ -116,7 +116,7 @@ private: NCoro::TTrampoline Trampoline_; - TIntrusiveList<TJoinWait> Waiters_; + TIntrusiveList<TJoinWait> Waiters_; bool Cancelled_ = false; bool Scheduled_ = false; }; diff --git a/library/cpp/coroutine/engine/poller.cpp b/library/cpp/coroutine/engine/poller.cpp index 4a8a33e4af..61164fa56b 100644 --- a/library/cpp/coroutine/engine/poller.cpp +++ b/library/cpp/coroutine/engine/poller.cpp @@ -82,9 +82,9 @@ namespace { } void Reserve(size_t size) { - E_.Reserve(size); - } - + E_.Reserve(size); + } + void Wait(TEvents& events, TInstant deadLine) { const size_t ret = P_.WaitD(~E_, +E_, deadLine); @@ -220,8 +220,8 @@ namespace { for (TFds::TConstIterator it = S_.Begin(); it != S_.End(); ++it) { t.Set(*it); } - - t.Reserve(Size()); + + t.Reserve(Size()); } void Set(const TChange& c) { diff --git a/library/cpp/coroutine/listener/listen.cpp b/library/cpp/coroutine/listener/listen.cpp index e7b56a3363..3d4e711d1d 100644 --- a/library/cpp/coroutine/listener/listen.cpp +++ b/library/cpp/coroutine/listener/listen.cpp @@ -65,18 +65,18 @@ private: FixIPv6ListenSocket(ListenSocket_); CheckedSetSockOpt(ListenSocket_, SOL_SOCKET, SO_REUSEADDR, 1, "reuse addr"); - - const TOptions& opts = Parent_->Opts_; - if (opts.SendBufSize) { - SetOutputBuffer(ListenSocket_, opts.SendBufSize); - } - if (opts.RecvBufSize) { - SetInputBuffer(ListenSocket_, opts.RecvBufSize); - } + + const TOptions& opts = Parent_->Opts_; + if (opts.SendBufSize) { + SetOutputBuffer(ListenSocket_, opts.SendBufSize); + } + if (opts.RecvBufSize) { + SetInputBuffer(ListenSocket_, opts.RecvBufSize); + } if (opts.ReusePort) { SetReusePort(ListenSocket_, opts.ReusePort); } - + SetNonBlock(ListenSocket_); if (bind(ListenSocket_, Addr_->Addr(), Addr_->Len()) < 0) { diff --git a/library/cpp/coroutine/listener/listen.h b/library/cpp/coroutine/listener/listen.h index 1c96e9ef4e..3a89cd3ecc 100644 --- a/library/cpp/coroutine/listener/listen.h +++ b/library/cpp/coroutine/listener/listen.h @@ -17,8 +17,8 @@ public: struct TOptions { inline TOptions() noexcept : ListenQueue(Max<size_t>()) - , SendBufSize(0) - , RecvBufSize(0) + , SendBufSize(0) + , RecvBufSize(0) , EnableDeferAccept(false) , ReusePort(false) { @@ -37,17 +37,17 @@ public: } inline TOptions& SetSendBufSize(unsigned size) noexcept { - SendBufSize = size; - - return *this; - } - + SendBufSize = size; + + return *this; + } + inline TOptions& SetRecvBufSize(unsigned size) noexcept { - RecvBufSize = size; - - return *this; - } - + RecvBufSize = size; + + return *this; + } + inline TOptions& SetReusePort(bool reusePort) noexcept { ReusePort = reusePort; @@ -55,8 +55,8 @@ public: } size_t ListenQueue; - unsigned SendBufSize; - unsigned RecvBufSize; + unsigned SendBufSize; + unsigned RecvBufSize; bool EnableDeferAccept; bool ReusePort; }; diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 531a404457..6689be684f 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -649,8 +649,8 @@ private: return true; } return false; - } - + } + inline bool IsHttpResponse() const noexcept { return IsResponse(FirstLine_); } diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 638f1f5df9..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -613,57 +613,57 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { Y_UNIT_TEST(TestHttpInputHeadRequest) { class THeadOnlyInput: public IInputStream { - public: - THeadOnlyInput() = default; - - private: - size_t DoRead(void* buf, size_t len) override { - if (Eof_) { - ythrow yexception() << "should not read after EOF"; - } - + public: + THeadOnlyInput() = default; + + private: + size_t DoRead(void* buf, size_t len) override { + if (Eof_) { + ythrow yexception() << "should not read after EOF"; + } + const size_t toWrite = Min(len, Data_.size() - Pos_); - if (toWrite == 0) { - Eof_ = true; - return 0; - } - - memcpy(buf, Data_.data() + Pos_, toWrite); - Pos_ += toWrite; - return toWrite; - } - - private: + if (toWrite == 0) { + Eof_ = true; + return 0; + } + + memcpy(buf, Data_.data() + Pos_, toWrite); + Pos_ += toWrite; + return toWrite; + } + + private: TString Data_{TStringBuf("HEAD / HTTP/1.1\r\nHost: yandex.ru\r\n\r\n")}; size_t Pos_{0}; bool Eof_{false}; - }; - THeadOnlyInput input; - THttpInput httpInput(&input); - - UNIT_ASSERT(!httpInput.HasContent()); - UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); - } - + }; + THeadOnlyInput input; + THttpInput httpInput(&input); + + UNIT_ASSERT(!httpInput.HasContent()); + UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); + } + Y_UNIT_TEST(TestHttpOutputResponseToHeadRequestNoZeroChunk) { - TStringStream request; + TStringStream request; request << "HEAD / HTTP/1.1\r\n" "Host: yandex.ru\r\n" "Connection: Keep-Alive\r\n" "\r\n"; - - TStringInput input(request.Str()); - THttpInput httpInput(&input); - - TStringStream outBuf; - THttpOutput out(&outBuf, &httpInput); - out.EnableKeepAlive(true); - out << "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n"; - out << ""; - out.Finish(); + + TStringInput input(request.Str()); + THttpInput httpInput(&input); + + TStringStream outBuf; + THttpOutput out(&outBuf, &httpInput); + out.EnableKeepAlive(true); + out << "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n"; + out << ""; + out.Finish(); TString result = outBuf.Str(); UNIT_ASSERT(!result.Contains(TStringBuf("0\r\n"))); - } + } Y_UNIT_TEST(TestHttpOutputDisableCompressionHeader) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp index 0db7ca4ea4..61364af997 100644 --- a/util/datetime/parser_ut.cpp +++ b/util/datetime/parser_ut.cpp @@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseHttp("Sun Nov 6 08:49:37 1994"), TInstant::ParseIso8601("1994-11-06T08:49:37Z")); - UNIT_ASSERT_VALUES_EQUAL( + UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseHttp("Mon, 19 Jan 2037 08:49:37 GMT"), TInstant::ParseIso8601("2037-01-19T08:49:37Z")); } diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h index 315e10ed48..b5d3f2051b 100644 --- a/util/generic/intrlist.h +++ b/util/generic/intrlist.h @@ -348,11 +348,11 @@ public: this->Swap(right); } - inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept { - this->Swap(rhs); - return *this; - } - + inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept { + this->Swap(rhs); + return *this; + } + inline explicit operator bool() const noexcept { return !Empty(); } @@ -611,16 +611,16 @@ public: this->Clear(); } - TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept { + TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept { TIntrusiveList<T, Tag>::operator=(std::move(rhs)); - return *this; - } - + return *this; + } + public: inline void Clear() noexcept { - this->ForEach([](auto* item) { - D::Destroy(item); - }); + this->ForEach([](auto* item) { + D::Destroy(item); + }); } inline static void Cut(TIterator begin, TIterator end) noexcept { diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp index 6f9649f6ef..eff7cdf2ee 100644 --- a/util/generic/intrlist_ut.cpp +++ b/util/generic/intrlist_ut.cpp @@ -14,12 +14,12 @@ class TListTest: public TTestBase { UNIT_TEST(TestQuickSort); UNIT_TEST(TestCut); UNIT_TEST(TestAppend); - UNIT_TEST(TestMoveCtor); - UNIT_TEST(TestMoveOpEq); - UNIT_TEST(TestListWithAutoDelete); - UNIT_TEST(TestListWithAutoDeleteMoveCtor); - UNIT_TEST(TestListWithAutoDeleteMoveOpEq); - UNIT_TEST(TestListWithAutoDeleteClear); + UNIT_TEST(TestMoveCtor); + UNIT_TEST(TestMoveOpEq); + UNIT_TEST(TestListWithAutoDelete); + UNIT_TEST(TestListWithAutoDeleteMoveCtor); + UNIT_TEST(TestListWithAutoDeleteMoveOpEq); + UNIT_TEST(TestListWithAutoDeleteClear); UNIT_TEST(TestSecondTag); UNIT_TEST_SUITE_END(); @@ -32,12 +32,12 @@ private: void TestQuickSort(); void TestCut(); void TestAppend(); - void TestMoveCtor(); - void TestMoveOpEq(); - void TestListWithAutoDelete(); - void TestListWithAutoDeleteMoveCtor(); - void TestListWithAutoDeleteMoveOpEq(); - void TestListWithAutoDeleteClear(); + void TestMoveCtor(); + void TestMoveOpEq(); + void TestListWithAutoDelete(); + void TestListWithAutoDeleteMoveCtor(); + void TestListWithAutoDeleteMoveOpEq(); + void TestListWithAutoDeleteClear(); void TestSecondTag(); }; @@ -50,18 +50,18 @@ public: { } - TInt(TInt&& rhs) noexcept - : Value_(rhs.Value_) - { - rhs.Value_ = 0xDEAD; - } - - TInt& operator=(TInt&& rhs) noexcept { - Value_ = rhs.Value_; - rhs.Value_ = 0xBEEF; - return *this; - } - + TInt(TInt&& rhs) noexcept + : Value_(rhs.Value_) + { + rhs.Value_ = 0xDEAD; + } + + TInt& operator=(TInt&& rhs) noexcept { + Value_ = rhs.Value_; + rhs.Value_ = 0xBEEF; + return *this; + } + inline operator int&() noexcept { return Value_; } @@ -82,12 +82,12 @@ public: } } - //TMyList(const TMyList& rhs) = default; - TMyList(TMyList&& rhs) noexcept = default; - - //operator=(const TMyList& rhs) = default; - TMyList& operator=(TMyList&& rhs) noexcept = default; - + //TMyList(const TMyList& rhs) = default; + TMyList(TMyList&& rhs) noexcept = default; + + //operator=(const TMyList& rhs) = default; + TMyList& operator=(TMyList&& rhs) noexcept = default; + inline ~TMyList() { while (!Empty()) { delete PopBack(); @@ -307,174 +307,174 @@ void TListTest::TestAppend() { ::TestAppend(0, 1); ::TestAppend(1, 1); } - + template <typename TListType> -static void CheckList(const TListType& lst) { - int i = 1; - for (typename TListType::TConstIterator it = lst.Begin(); it != lst.End(); ++it, ++i) { - UNIT_ASSERT_EQUAL(*it, i); - } -} - -void TListTest::TestMoveCtor() { +static void CheckList(const TListType& lst) { + int i = 1; + for (typename TListType::TConstIterator it = lst.Begin(); it != lst.End(); ++it, ++i) { + UNIT_ASSERT_EQUAL(*it, i); + } +} + +void TListTest::TestMoveCtor() { const int N{42}; TMyList lst{N}; - UNIT_ASSERT(!lst.Empty()); - UNIT_ASSERT_EQUAL(lst.Size(), N); - - CheckList(lst); + UNIT_ASSERT(!lst.Empty()); + UNIT_ASSERT_EQUAL(lst.Size(), N); + + CheckList(lst); TMyList nextLst{std::move(lst)}; - UNIT_ASSERT(lst.Empty()); - CheckList(nextLst); -} - -void TListTest::TestMoveOpEq() { + UNIT_ASSERT(lst.Empty()); + CheckList(nextLst); +} + +void TListTest::TestMoveOpEq() { const int N{42}; TMyList lst{N}; - UNIT_ASSERT(!lst.Empty()); - UNIT_ASSERT_EQUAL(lst.Size(), N); - CheckList(lst); - + UNIT_ASSERT(!lst.Empty()); + UNIT_ASSERT_EQUAL(lst.Size(), N); + CheckList(lst); + const int M{2}; - TMyList nextLst(M); - UNIT_ASSERT(!nextLst.Empty()); - UNIT_ASSERT_EQUAL(nextLst.Size(), M); - CheckList(nextLst); - - nextLst = std::move(lst); - UNIT_ASSERT(!nextLst.Empty()); - UNIT_ASSERT_EQUAL(nextLst.Size(), N); - CheckList(nextLst); -} - -class TSelfCountingInt: public TIntrusiveListItem<TSelfCountingInt> { -public: - TSelfCountingInt(int& counter, int value) noexcept + TMyList nextLst(M); + UNIT_ASSERT(!nextLst.Empty()); + UNIT_ASSERT_EQUAL(nextLst.Size(), M); + CheckList(nextLst); + + nextLst = std::move(lst); + UNIT_ASSERT(!nextLst.Empty()); + UNIT_ASSERT_EQUAL(nextLst.Size(), N); + CheckList(nextLst); +} + +class TSelfCountingInt: public TIntrusiveListItem<TSelfCountingInt> { +public: + TSelfCountingInt(int& counter, int value) noexcept : Counter_(counter) , Value_(value) { - ++Counter_; - } - - TSelfCountingInt(TSelfCountingInt&& rhs) noexcept + ++Counter_; + } + + TSelfCountingInt(TSelfCountingInt&& rhs) noexcept : Counter_(rhs.Counter_) , Value_(rhs.Value_) { - rhs.Value_ = 0xDEAD; - } - - TSelfCountingInt& operator=(TSelfCountingInt&& rhs) noexcept { - Value_ = rhs.Value_; - rhs.Value_ = 0xBEEF; - return *this; - } - - ~TSelfCountingInt() noexcept { - --Counter_; - } - - inline operator int&() noexcept { - return Value_; - } - - inline operator const int&() const noexcept { - return Value_; - } - -private: - int& Counter_; - int Value_; -}; - -struct TSelfCountingIntDelete { - static void Destroy(TSelfCountingInt* i) noexcept { - delete i; - } -}; - -void TListTest::TestListWithAutoDelete() { + rhs.Value_ = 0xDEAD; + } + + TSelfCountingInt& operator=(TSelfCountingInt&& rhs) noexcept { + Value_ = rhs.Value_; + rhs.Value_ = 0xBEEF; + return *this; + } + + ~TSelfCountingInt() noexcept { + --Counter_; + } + + inline operator int&() noexcept { + return Value_; + } + + inline operator const int&() const noexcept { + return Value_; + } + +private: + int& Counter_; + int Value_; +}; + +struct TSelfCountingIntDelete { + static void Destroy(TSelfCountingInt* i) noexcept { + delete i; + } +}; + +void TListTest::TestListWithAutoDelete() { using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>; int counter{0}; - { + { TListType lst; - UNIT_ASSERT(lst.Empty()); - lst.PushFront(new TSelfCountingInt(counter, 2)); - UNIT_ASSERT_EQUAL(lst.Size(), 1); - UNIT_ASSERT_EQUAL(counter, 1); - lst.PushFront(new TSelfCountingInt(counter, 1)); - UNIT_ASSERT_EQUAL(lst.Size(), 2); - UNIT_ASSERT_EQUAL(counter, 2); - CheckList(lst); - } - - UNIT_ASSERT_EQUAL(counter, 0); -} - -void TListTest::TestListWithAutoDeleteMoveCtor() { + UNIT_ASSERT(lst.Empty()); + lst.PushFront(new TSelfCountingInt(counter, 2)); + UNIT_ASSERT_EQUAL(lst.Size(), 1); + UNIT_ASSERT_EQUAL(counter, 1); + lst.PushFront(new TSelfCountingInt(counter, 1)); + UNIT_ASSERT_EQUAL(lst.Size(), 2); + UNIT_ASSERT_EQUAL(counter, 2); + CheckList(lst); + } + + UNIT_ASSERT_EQUAL(counter, 0); +} + +void TListTest::TestListWithAutoDeleteMoveCtor() { using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>; int counter{0}; - { + { TListType lst; - lst.PushFront(new TSelfCountingInt(counter, 2)); - lst.PushFront(new TSelfCountingInt(counter, 1)); - UNIT_ASSERT_EQUAL(lst.Size(), 2); - UNIT_ASSERT_EQUAL(counter, 2); - CheckList(lst); - + lst.PushFront(new TSelfCountingInt(counter, 2)); + lst.PushFront(new TSelfCountingInt(counter, 1)); + UNIT_ASSERT_EQUAL(lst.Size(), 2); + UNIT_ASSERT_EQUAL(counter, 2); + CheckList(lst); + TListType nextList(std::move(lst)); - UNIT_ASSERT_EQUAL(nextList.Size(), 2); - CheckList(nextList); - UNIT_ASSERT_EQUAL(counter, 2); - } - - UNIT_ASSERT_EQUAL(counter, 0); -} - -void TListTest::TestListWithAutoDeleteMoveOpEq() { + UNIT_ASSERT_EQUAL(nextList.Size(), 2); + CheckList(nextList); + UNIT_ASSERT_EQUAL(counter, 2); + } + + UNIT_ASSERT_EQUAL(counter, 0); +} + +void TListTest::TestListWithAutoDeleteMoveOpEq() { using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>; int counter{0}; - { + { TListType lst; - lst.PushFront(new TSelfCountingInt(counter, 2)); - lst.PushFront(new TSelfCountingInt(counter, 1)); - UNIT_ASSERT_EQUAL(lst.Size(), 2); - UNIT_ASSERT_EQUAL(counter, 2); - CheckList(lst); - + lst.PushFront(new TSelfCountingInt(counter, 2)); + lst.PushFront(new TSelfCountingInt(counter, 1)); + UNIT_ASSERT_EQUAL(lst.Size(), 2); + UNIT_ASSERT_EQUAL(counter, 2); + CheckList(lst); + TListType nextList; - UNIT_ASSERT(nextList.Empty()); - nextList = std::move(lst); - UNIT_ASSERT_EQUAL(nextList.Size(), 2); - CheckList(nextList); - UNIT_ASSERT_EQUAL(counter, 2); - } - - UNIT_ASSERT_EQUAL(counter, 0); -} - -void TListTest::TestListWithAutoDeleteClear() { + UNIT_ASSERT(nextList.Empty()); + nextList = std::move(lst); + UNIT_ASSERT_EQUAL(nextList.Size(), 2); + CheckList(nextList); + UNIT_ASSERT_EQUAL(counter, 2); + } + + UNIT_ASSERT_EQUAL(counter, 0); +} + +void TListTest::TestListWithAutoDeleteClear() { using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>; - int counter{0}; - { + int counter{0}; + { TListType lst; - UNIT_ASSERT(lst.Empty()); - lst.PushFront(new TSelfCountingInt(counter, 2)); - UNIT_ASSERT_EQUAL(lst.Size(), 1); - UNIT_ASSERT_EQUAL(counter, 1); - lst.PushFront(new TSelfCountingInt(counter, 1)); - UNIT_ASSERT_EQUAL(lst.Size(), 2); - UNIT_ASSERT_EQUAL(counter, 2); - CheckList(lst); - - lst.Clear(); - UNIT_ASSERT(lst.Empty()); - UNIT_ASSERT_EQUAL(counter, 0); - lst.PushFront(new TSelfCountingInt(counter, 1)); - UNIT_ASSERT_EQUAL(lst.Size(), 1); - } - - UNIT_ASSERT_EQUAL(counter, 0); -} + UNIT_ASSERT(lst.Empty()); + lst.PushFront(new TSelfCountingInt(counter, 2)); + UNIT_ASSERT_EQUAL(lst.Size(), 1); + UNIT_ASSERT_EQUAL(counter, 1); + lst.PushFront(new TSelfCountingInt(counter, 1)); + UNIT_ASSERT_EQUAL(lst.Size(), 2); + UNIT_ASSERT_EQUAL(counter, 2); + CheckList(lst); + + lst.Clear(); + UNIT_ASSERT(lst.Empty()); + UNIT_ASSERT_EQUAL(counter, 0); + lst.PushFront(new TSelfCountingInt(counter, 1)); + UNIT_ASSERT_EQUAL(lst.Size(), 1); + } + + UNIT_ASSERT_EQUAL(counter, 0); +} struct TSecondTag {}; diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 8a397344c1..4f6e804346 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -448,48 +448,48 @@ bool HasLocalAddress(SOCKET socket) { return IsSame(localAddr, remoteAddr); } -namespace { -#if defined(_linux_) +namespace { +#if defined(_linux_) #if !defined(TCP_FASTOPEN) #define TCP_FASTOPEN 23 #endif -#endif - -#if defined(TCP_FASTOPEN) - struct TTcpFastOpenFeature { - inline TTcpFastOpenFeature() - : HasFastOpen_(false) - { - TSocketHolder tmp(socket(AF_INET, SOCK_STREAM, 0)); - int val = 1; - int ret = SetSockOpt(tmp, IPPROTO_TCP, TCP_FASTOPEN, val); - HasFastOpen_ = (ret == 0); - } - - inline void SetFastOpen(SOCKET s, int qlen) const { - if (HasFastOpen_) { - CheckedSetSockOpt(s, IPPROTO_TCP, TCP_FASTOPEN, qlen, "setting TCP_FASTOPEN"); - } - } - - static inline const TTcpFastOpenFeature* Instance() noexcept { - return Singleton<TTcpFastOpenFeature>(); - } - - bool HasFastOpen_; - }; -#endif -} - -void SetTcpFastOpen(SOCKET s, int qlen) { -#if defined(TCP_FASTOPEN) - TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen); -#else +#endif + +#if defined(TCP_FASTOPEN) + struct TTcpFastOpenFeature { + inline TTcpFastOpenFeature() + : HasFastOpen_(false) + { + TSocketHolder tmp(socket(AF_INET, SOCK_STREAM, 0)); + int val = 1; + int ret = SetSockOpt(tmp, IPPROTO_TCP, TCP_FASTOPEN, val); + HasFastOpen_ = (ret == 0); + } + + inline void SetFastOpen(SOCKET s, int qlen) const { + if (HasFastOpen_) { + CheckedSetSockOpt(s, IPPROTO_TCP, TCP_FASTOPEN, qlen, "setting TCP_FASTOPEN"); + } + } + + static inline const TTcpFastOpenFeature* Instance() noexcept { + return Singleton<TTcpFastOpenFeature>(); + } + + bool HasFastOpen_; + }; +#endif +} + +void SetTcpFastOpen(SOCKET s, int qlen) { +#if defined(TCP_FASTOPEN) + TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen); +#else Y_UNUSED(s); Y_UNUSED(qlen); -#endif -} - +#endif +} + static bool IsBlocked(int lasterr) noexcept { return lasterr == EAGAIN || lasterr == EWOULDBLOCK; } @@ -953,7 +953,7 @@ namespace { insert("localhost.localdomain"); insert("localhost6"); insert("localhost6.localdomain6"); - insert("::1"); + insert("::1"); } inline bool IsLocalName(const char* name) const noexcept { diff --git a/util/network/socket.h b/util/network/socket.h index 68cceb0f5f..40c8648b40 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -117,7 +117,7 @@ void SetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr, int tos); int GetSocketToS(SOCKET s); int GetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr); void SetSocketPriority(SOCKET s, int priority); -void SetTcpFastOpen(SOCKET s, int qlen); +void SetTcpFastOpen(SOCKET s, int qlen); /** * Deprecated, consider using HasSocketDataToRead instead. **/ diff --git a/util/stream/format.h b/util/stream/format.h index 297725d18e..b033208a1b 100644 --- a/util/stream/format.h +++ b/util/stream/format.h @@ -201,7 +201,7 @@ namespace NFormatPrivate { * @param value Value to output. * @param width Target total width. * @param padc Character to use for padding. - * @see RightPad + * @see RightPad */ template <typename T> static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept { @@ -221,7 +221,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N * * Example usage: * @code - * stream << RightPad("column1", 10, ' '); // Will output "column1 " + * stream << RightPad("column1", 10, ' '); // Will output "column1 " * @endcode * * @param value Value to output. diff --git a/util/system/context.cpp b/util/system/context.cpp index f03be0cccc..ad99309088 100644 --- a/util/system/context.cpp +++ b/util/system/context.cpp @@ -1,4 +1,4 @@ -#include "compiler.h" +#include "compiler.h" #include "defaults.h" #include "event.h" #include "thread.h" @@ -195,7 +195,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c) } void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept { - if (Y_LIKELY(__mysetjmp(Buf_) == 0)) { + if (Y_LIKELY(__mysetjmp(Buf_) == 0)) { #if defined(_asan_enabled_) || defined(_tsan_enabled_) next->San_.BeforeSwitch(&San_); #endif diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp index 5f6ce4e218..057a814f0a 100644 --- a/util/system/fasttime.cpp +++ b/util/system/fasttime.cpp @@ -136,9 +136,9 @@ namespace { inline void Add(const TSample& s) noexcept { S_[(C_++) % N] = s; - if (C_ > 1) { - ReCalc(); - } + if (C_ > 1) { + ReCalc(); + } } inline B Predict(A a) const noexcept { |