aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArseny Smalyuk <smalukav@gmail.com>2022-02-10 16:48:05 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:05 +0300
commit5f8a2ce7b1dc3b3e1fae197610f189e7ed1d5723 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13
parent12559cd7f2fa0cf54ffb0d961949fea58c0e18cb (diff)
downloadydb-5f8a2ce7b1dc3b3e1fae197610f189e7ed1d5723.tar.gz
Restoring authorship annotation for Arseny Smalyuk <smalukav@gmail.com>. Commit 2 of 2.
-rw-r--r--contrib/libs/pire/pire/re_parser.y18
-rw-r--r--contrib/libs/zlib/trees.c8
-rw-r--r--library/cpp/coroutine/engine/callbacks.h14
-rw-r--r--library/cpp/coroutine/engine/coroutine_ut.cpp6
-rw-r--r--library/cpp/coroutine/engine/impl.cpp58
-rw-r--r--library/cpp/coroutine/engine/impl.h10
-rw-r--r--library/cpp/coroutine/engine/network.cpp2
-rw-r--r--library/cpp/coroutine/engine/poller.cpp34
-rw-r--r--library/cpp/http/io/compression.cpp62
-rw-r--r--library/cpp/http/io/compression.h62
-rw-r--r--library/cpp/http/io/compression_ut.cpp44
-rw-r--r--library/cpp/http/io/stream.cpp84
-rw-r--r--library/cpp/http/io/stream.h22
-rw-r--r--library/cpp/http/io/stream_ut.cpp54
-rw-r--r--library/cpp/http/io/ut/ya.make4
-rw-r--r--library/cpp/http/io/ya.make4
-rw-r--r--util/generic/xrange.h4
-rw-r--r--util/network/poller.cpp8
-rw-r--r--util/network/poller.h2
-rw-r--r--util/network/poller_ut.cpp48
-rw-r--r--util/network/pollerimpl.h28
-rw-r--r--util/stream/zlib.cpp32
-rw-r--r--util/stream/zlib_ut.cpp180
23 files changed, 394 insertions, 394 deletions
diff --git a/contrib/libs/pire/pire/re_parser.y b/contrib/libs/pire/pire/re_parser.y
index f2f845c2d3..dbad88e287 100644
--- a/contrib/libs/pire/pire/re_parser.y
+++ b/contrib/libs/pire/pire/re_parser.y
@@ -70,8 +70,8 @@ void AppendRange(const Encoding& encoding, Fsm& a, const Term::CharacterRange& c
%term YRE_AND
%term YRE_NOT
-%destructor { delete $$; } <>
-
+%destructor { delete $$; } <>
+
%%
regexp
@@ -80,23 +80,23 @@ regexp
ConvertToFSM(rlex.Encoding(), $1);
DoSwap(rlex.Retval(), *$1);
delete $1;
- $$ = nullptr;
+ $$ = nullptr;
}
;
alternative
: conjunction
- | alternative '|' conjunction { ConvertToFSM(rlex.Encoding(), ($$ = $1)) |= ConvertToFSM(rlex.Encoding(), $3); delete $2; delete $3; }
+ | alternative '|' conjunction { ConvertToFSM(rlex.Encoding(), ($$ = $1)) |= ConvertToFSM(rlex.Encoding(), $3); delete $2; delete $3; }
;
conjunction
: negation
- | conjunction YRE_AND negation { ConvertToFSM(rlex.Encoding(), ($$ = $1)) &= ConvertToFSM(rlex.Encoding(), $3); delete $2; delete $3; }
+ | conjunction YRE_AND negation { ConvertToFSM(rlex.Encoding(), ($$ = $1)) &= ConvertToFSM(rlex.Encoding(), $3); delete $2; delete $3; }
;
negation
: concatenation
- | YRE_NOT concatenation { ConvertToFSM(rlex.Encoding(), ($$ = $2)).Complement(); delete $1; }
+ | YRE_NOT concatenation { ConvertToFSM(rlex.Encoding(), ($$ = $2)).Complement(); delete $1; }
;
concatenation
@@ -150,7 +150,7 @@ term
| YRE_DOT
| '^'
| '$'
- | '(' alternative ')' { $$ = $2; rlex.Parenthesized($$->As<Fsm>()); delete $1; delete $3; }
+ | '(' alternative ')' { $$ = $2; rlex.Parenthesized($$->As<Fsm>()); delete $1; delete $3; }
;
%%
@@ -161,8 +161,8 @@ int yylex(YYSTYPE* lval, Pire::Lexer& rlex)
Pire::Term term = rlex.Lex();
if (!term.Value().Empty())
*lval = new Any(term.Value());
- else
- *lval = nullptr;
+ else
+ *lval = nullptr;
return term.Type();
} catch (Pire::Error &e) {
rlex.SetError(e.what());
diff --git a/contrib/libs/zlib/trees.c b/contrib/libs/zlib/trees.c
index 66f57e5437..912f59dc55 100644
--- a/contrib/libs/zlib/trees.c
+++ b/contrib/libs/zlib/trees.c
@@ -870,10 +870,10 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
bi_windup(s); /* align on byte boundary */
put_short(s, (ush)stored_len);
put_short(s, (ush)~stored_len);
- if (stored_len) {
- zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
- s->pending += stored_len;
- }
+ if (stored_len) {
+ zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
+ s->pending += stored_len;
+ }
#ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3;
diff --git a/library/cpp/coroutine/engine/callbacks.h b/library/cpp/coroutine/engine/callbacks.h
index e578ae2b35..e81b17344f 100644
--- a/library/cpp/coroutine/engine/callbacks.h
+++ b/library/cpp/coroutine/engine/callbacks.h
@@ -6,13 +6,13 @@ class TContExecutor;
namespace NCoro {
class IScheduleCallback {
public:
- virtual void OnSchedule(TContExecutor&, TCont&) = 0;
- virtual void OnUnschedule(TContExecutor&) = 0;
- };
+ virtual void OnSchedule(TContExecutor&, TCont&) = 0;
+ virtual void OnUnschedule(TContExecutor&) = 0;
+ };
- class IEnterPollerCallback {
- public:
- virtual void OnEnterPoller() = 0;
- virtual void OnExitPoller() = 0;
+ class IEnterPollerCallback {
+ public:
+ virtual void OnEnterPoller() = 0;
+ virtual void OnExitPoller() = 0;
};
}
diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp
index 8daec28f14..8b372496a2 100644
--- a/library/cpp/coroutine/engine/coroutine_ut.cpp
+++ b/library/cpp/coroutine/engine/coroutine_ut.cpp
@@ -36,7 +36,7 @@ class TCoroTest: public TTestBase {
// UNIT_TEST(TestFastPathWakeEpoll)
UNIT_TEST(TestFastPathWakeKqueue)
UNIT_TEST(TestFastPathWakePoll)
- UNIT_TEST(TestFastPathWakeSelect)
+ UNIT_TEST(TestFastPathWakeSelect)
UNIT_TEST(TestLegacyCancelYieldRaceBug)
UNIT_TEST(TestJoinRescheduleBug);
UNIT_TEST(TestEventQueue)
@@ -943,7 +943,7 @@ void TCoroTest::TestPollEngines() {
}
void TCoroTest::TestPause() {
- TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing()};
+ TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing()};
int i = 0;
executor.CreateOwned([&](TCont*) {
@@ -993,7 +993,7 @@ void TCoroTest::TestOverrideTime() {
};
TTime time;
- TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing(), &time};
+ TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing(), &time};
executor.CreateOwned([&](TCont* cont) {
UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Zero());
diff --git a/library/cpp/coroutine/engine/impl.cpp b/library/cpp/coroutine/engine/impl.cpp
index 578d06498b..7ae6f74051 100644
--- a/library/cpp/coroutine/engine/impl.cpp
+++ b/library/cpp/coroutine/engine/impl.cpp
@@ -119,14 +119,14 @@ void TCont::ReSchedule() noexcept {
TContExecutor::TContExecutor(
uint32_t defaultStackSize,
THolder<IPollerFace> poller,
- NCoro::IScheduleCallback* scheduleCallback,
- NCoro::IEnterPollerCallback* enterPollerCallback,
+ NCoro::IScheduleCallback* scheduleCallback,
+ NCoro::IEnterPollerCallback* enterPollerCallback,
NCoro::NStack::EGuard defaultGuard,
TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings,
NCoro::ITime* time
)
- : ScheduleCallback_(scheduleCallback)
- , EnterPollerCallback_(enterPollerCallback)
+ : ScheduleCallback_(scheduleCallback)
+ , EnterPollerCallback_(enterPollerCallback)
, DefaultStackSize_(defaultStackSize)
, Poller_(std::move(poller))
, Time_(time)
@@ -171,21 +171,21 @@ void TContExecutor::WaitForIO() {
// to prevent ourselves from locking out of io by constantly waking coroutines.
if (ReadyNext_.Empty()) {
- if (EnterPollerCallback_) {
- EnterPollerCallback_->OnEnterPoller();
- }
+ if (EnterPollerCallback_) {
+ EnterPollerCallback_->OnEnterPoller();
+ }
Poll(next);
- if (EnterPollerCallback_) {
- EnterPollerCallback_->OnExitPoller();
- }
+ if (EnterPollerCallback_) {
+ EnterPollerCallback_->OnExitPoller();
+ }
} else if (LastPoll_ + TDuration::MilliSeconds(5) < now) {
- if (EnterPollerCallback_) {
- EnterPollerCallback_->OnEnterPoller();
- }
+ if (EnterPollerCallback_) {
+ EnterPollerCallback_->OnEnterPoller();
+ }
Poll(now);
- if (EnterPollerCallback_) {
- EnterPollerCallback_->OnExitPoller();
- }
+ if (EnterPollerCallback_) {
+ EnterPollerCallback_->OnExitPoller();
+ }
}
Ready_.Append(ReadyNext_);
@@ -296,8 +296,8 @@ TCont* RunningCont() {
return thisThreadExecutor ? thisThreadExecutor->Running() : nullptr;
}
-void TContExecutor::RunScheduler() noexcept {
- try {
+void TContExecutor::RunScheduler() noexcept {
+ try {
TContExecutor* const prev = ThisThreadExecutor();
ThisThreadExecutor() = this;
TCont* caller = Current_;
@@ -306,27 +306,27 @@ void TContExecutor::RunScheduler() noexcept {
ThisThreadExecutor() = prev;
};
- while (true) {
- if (ScheduleCallback_ && Current_) {
- ScheduleCallback_->OnUnschedule(*this);
+ while (true) {
+ if (ScheduleCallback_ && Current_) {
+ ScheduleCallback_->OnUnschedule(*this);
}
WaitForIO();
DeleteScheduled();
- Ready_.Append(ReadyNext_);
+ Ready_.Append(ReadyNext_);
- if (Ready_.Empty()) {
+ if (Ready_.Empty()) {
Current_ = nullptr;
if (caller) {
context->SwitchTo(&SchedContext_);
}
- break;
- }
+ break;
+ }
TCont* cont = Ready_.PopFront();
- if (ScheduleCallback_) {
- ScheduleCallback_->OnSchedule(*this, *cont);
+ if (ScheduleCallback_) {
+ ScheduleCallback_->OnSchedule(*this, *cont);
}
Current_ = cont;
@@ -343,8 +343,8 @@ void TContExecutor::RunScheduler() noexcept {
if (caller) {
break;
}
- }
- } catch (...) {
+ }
+ } catch (...) {
TBackTrace::FromCurrentException().PrintTo(Cerr);
Y_FAIL("Uncaught exception in the scheduler: %s", CurrentExceptionMessage().c_str());
}
diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h
index 0b892749a0..283a96ecf1 100644
--- a/library/cpp/coroutine/engine/impl.h
+++ b/library/cpp/coroutine/engine/impl.h
@@ -1,6 +1,6 @@
#pragma once
-#include "callbacks.h"
+#include "callbacks.h"
#include "cont_poller.h"
#include "iostatus.h"
#include "poller.h"
@@ -154,7 +154,7 @@ public:
uint32_t defaultStackSize,
THolder<IPollerFace> poller = IPollerFace::Default(),
NCoro::IScheduleCallback* = nullptr,
- NCoro::IEnterPollerCallback* = nullptr,
+ NCoro::IEnterPollerCallback* = nullptr,
NCoro::NStack::EGuard stackGuard = NCoro::NStack::EGuard::Canary,
TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings = Nothing(),
NCoro::ITime* time = nullptr
@@ -273,7 +273,7 @@ private:
void Exit(TCont* cont) noexcept;
- void RunScheduler() noexcept;
+ void RunScheduler() noexcept;
void ScheduleToDelete(TCont* cont) noexcept;
@@ -288,8 +288,8 @@ private:
void Poll(TInstant deadline);
private:
- NCoro::IScheduleCallback* const ScheduleCallback_ = nullptr;
- NCoro::IEnterPollerCallback* const EnterPollerCallback_ = nullptr;
+ NCoro::IScheduleCallback* const ScheduleCallback_ = nullptr;
+ NCoro::IEnterPollerCallback* const EnterPollerCallback_ = nullptr;
const uint32_t DefaultStackSize_;
THolder<NCoro::NStack::IAllocator> StackAllocator_;
diff --git a/library/cpp/coroutine/engine/network.cpp b/library/cpp/coroutine/engine/network.cpp
index 6315532d3f..85b647d210 100644
--- a/library/cpp/coroutine/engine/network.cpp
+++ b/library/cpp/coroutine/engine/network.cpp
@@ -295,7 +295,7 @@ namespace NCoro {
if (!IsBlocked(err)) {
return -err;
- }
+ }
err = PollD(cont, s, CONT_POLL_READ, deadline);
diff --git a/library/cpp/coroutine/engine/poller.cpp b/library/cpp/coroutine/engine/poller.cpp
index 8aeff4e965..61164fa56b 100644
--- a/library/cpp/coroutine/engine/poller.cpp
+++ b/library/cpp/coroutine/engine/poller.cpp
@@ -88,8 +88,8 @@ namespace {
void Wait(TEvents& events, TInstant deadLine) {
const size_t ret = P_.WaitD(~E_, +E_, deadLine);
- events.reserve(ret);
-
+ events.reserve(ret);
+
for (size_t i = 0; i < ret; ++i) {
const TInternalEvent* ie = ~E_ + i;
@@ -199,12 +199,12 @@ namespace {
ret |= POLLOUT;
}
-#if defined(_linux_)
- if (flags & CONT_POLL_RDHUP) {
- ret |= POLLRDHUP;
- }
-#endif
-
+#if defined(_linux_)
+ if (flags & CONT_POLL_RDHUP) {
+ ret |= POLLRDHUP;
+ }
+#endif
+
return ret;
}
@@ -248,12 +248,12 @@ namespace {
const ssize_t ret = PollD(T_.data(), (nfds_t) T_.size(), deadLine);
- if (ret <= 0) {
+ if (ret <= 0) {
return;
}
events.reserve(T_.size());
-
+
for (size_t i = 0; i < T_.size(); ++i) {
const pollfd& pfd = T_[i];
const short ev = pfd.revents;
@@ -274,12 +274,12 @@ namespace {
filter |= CONT_POLL_WRITE;
}
-#if defined(_linux_)
- if (ev & POLLRDHUP) {
- filter |= CONT_POLL_RDHUP;
- }
-#endif
-
+#if defined(_linux_)
+ if (ev & POLLRDHUP) {
+ filter |= CONT_POLL_RDHUP;
+ }
+#endif
+
if (ev & POLLERR) {
status = EIO;
} else if (ev & POLLHUP && pfd.events & POLLOUT) {
@@ -290,7 +290,7 @@ namespace {
}
if (status) {
- filter = CONT_POLL_READ | CONT_POLL_WRITE | CONT_POLL_RDHUP;
+ filter = CONT_POLL_READ | CONT_POLL_WRITE | CONT_POLL_RDHUP;
}
const TEvent res = {
diff --git a/library/cpp/http/io/compression.cpp b/library/cpp/http/io/compression.cpp
index a4578813f4..8fa1f62ae6 100644
--- a/library/cpp/http/io/compression.cpp
+++ b/library/cpp/http/io/compression.cpp
@@ -1,4 +1,4 @@
-#include "compression.h"
+#include "compression.h"
#if defined(ENABLE_GPL)
#include <library/cpp/streams/lz/lz.h>
@@ -14,53 +14,53 @@
#include <util/stream/zlib.h>
-TCompressionCodecFactory::TCompressionCodecFactory() {
- auto gzip = [](auto s) {
- return MakeHolder<TZLibDecompress>(s);
+TCompressionCodecFactory::TCompressionCodecFactory() {
+ auto gzip = [](auto s) {
+ return MakeHolder<TZLibDecompress>(s);
};
- Add("gzip", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::GZip); });
- Add("deflate", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::ZLib); });
- Add("br", [](auto s) { return MakeHolder<TBrotliDecompress>(s); }, [](auto s) { return MakeHolder<TBrotliCompress>(s, 4); });
- Add("x-gzip", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::GZip); });
- Add("x-deflate", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::ZLib); });
+ Add("gzip", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::GZip); });
+ Add("deflate", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::ZLib); });
+ Add("br", [](auto s) { return MakeHolder<TBrotliDecompress>(s); }, [](auto s) { return MakeHolder<TBrotliCompress>(s, 4); });
+ Add("x-gzip", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::GZip); });
+ Add("x-deflate", gzip, [](auto s) { return MakeHolder<TZLibCompress>(s, ZLib::ZLib); });
#if defined(ENABLE_GPL)
- const ui16 bs = 32 * 1024;
+ const ui16 bs = 32 * 1024;
- Add("y-lzo", [](auto s) { return MakeHolder<TLzoDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzoCompress> >(s, bs); });
- Add("y-lzf", [](auto s) { return MakeHolder<TLzfDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzfCompress> >(s, bs); });
- Add("y-lzq", [](auto s) { return MakeHolder<TLzqDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzqCompress> >(s, bs); });
+ Add("y-lzo", [](auto s) { return MakeHolder<TLzoDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzoCompress> >(s, bs); });
+ Add("y-lzf", [](auto s) { return MakeHolder<TLzfDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzfCompress> >(s, bs); });
+ Add("y-lzq", [](auto s) { return MakeHolder<TLzqDecompress>(s); }, [bs](auto s) { return MakeHolder<TLazy<TLzqCompress> >(s, bs); });
#endif
- Add("y-bzip2", [](auto s) { return MakeHolder<TBZipDecompress>(s); }, [](auto s) { return MakeHolder<TBZipCompress>(s); });
- Add("y-lzma", [](auto s) { return MakeHolder<TLzmaDecompress>(s); }, [](auto s) { return MakeHolder<TLzmaCompress>(s); });
+ Add("y-bzip2", [](auto s) { return MakeHolder<TBZipDecompress>(s); }, [](auto s) { return MakeHolder<TBZipCompress>(s); });
+ Add("y-lzma", [](auto s) { return MakeHolder<TLzmaDecompress>(s); }, [](auto s) { return MakeHolder<TLzmaCompress>(s); });
- for (auto codecName : NBlockCodecs::ListAllCodecs()) {
- if (codecName.StartsWith("zstd06")) {
- continue;
+ for (auto codecName : NBlockCodecs::ListAllCodecs()) {
+ if (codecName.StartsWith("zstd06")) {
+ continue;
}
- if (codecName.StartsWith("zstd08")) {
- continue;
+ if (codecName.StartsWith("zstd08")) {
+ continue;
}
- auto codec = NBlockCodecs::Codec(codecName);
+ auto codec = NBlockCodecs::Codec(codecName);
- auto enc = [codec](auto s) {
- return MakeHolder<NBlockCodecs::TCodedOutput>(s, codec, 32 * 1024);
- };
+ auto enc = [codec](auto s) {
+ return MakeHolder<NBlockCodecs::TCodedOutput>(s, codec, 32 * 1024);
+ };
- auto dec = [codec](auto s) {
- return MakeHolder<NBlockCodecs::TDecodedInput>(s, codec);
+ auto dec = [codec](auto s) {
+ return MakeHolder<NBlockCodecs::TDecodedInput>(s, codec);
};
- Add(TString("z-") + codecName, dec, enc);
+ Add(TString("z-") + codecName, dec, enc);
}
}
-void TCompressionCodecFactory::Add(TStringBuf name, TDecoderConstructor d, TEncoderConstructor e) {
- Strings_.emplace_back(name);
- Codecs_[Strings_.back()] = TCodec{d, e};
- BestCodecs_.emplace_back(Strings_.back());
+void TCompressionCodecFactory::Add(TStringBuf name, TDecoderConstructor d, TEncoderConstructor e) {
+ Strings_.emplace_back(name);
+ Codecs_[Strings_.back()] = TCodec{d, e};
+ BestCodecs_.emplace_back(Strings_.back());
}
diff --git a/library/cpp/http/io/compression.h b/library/cpp/http/io/compression.h
index d93f628739..f16c4a18eb 100644
--- a/library/cpp/http/io/compression.h
+++ b/library/cpp/http/io/compression.h
@@ -1,52 +1,52 @@
#pragma once
-#include "stream.h"
+#include "stream.h"
#include <util/generic/deque.h>
-#include <util/generic/hash.h>
+#include <util/generic/hash.h>
-class TCompressionCodecFactory {
+class TCompressionCodecFactory {
public:
- using TDecoderConstructor = std::function<THolder<IInputStream>(IInputStream*)>;
- using TEncoderConstructor = std::function<THolder<IOutputStream>(IOutputStream*)>;
+ using TDecoderConstructor = std::function<THolder<IInputStream>(IInputStream*)>;
+ using TEncoderConstructor = std::function<THolder<IOutputStream>(IOutputStream*)>;
- TCompressionCodecFactory();
+ TCompressionCodecFactory();
- static inline TCompressionCodecFactory& Instance() noexcept {
- return *SingletonWithPriority<TCompressionCodecFactory, 0>();
- }
+ static inline TCompressionCodecFactory& Instance() noexcept {
+ return *SingletonWithPriority<TCompressionCodecFactory, 0>();
+ }
- inline const TDecoderConstructor* FindDecoder(TStringBuf name) const {
- if (auto codec = Codecs_.FindPtr(name)) {
- return &codec->Decoder;
- }
+ inline const TDecoderConstructor* FindDecoder(TStringBuf name) const {
+ if (auto codec = Codecs_.FindPtr(name)) {
+ return &codec->Decoder;
+ }
- return nullptr;
- }
+ return nullptr;
+ }
- inline const TEncoderConstructor* FindEncoder(TStringBuf name) const {
- if (auto codec = Codecs_.FindPtr(name)) {
- return &codec->Encoder;
- }
+ inline const TEncoderConstructor* FindEncoder(TStringBuf name) const {
+ if (auto codec = Codecs_.FindPtr(name)) {
+ return &codec->Encoder;
+ }
- return nullptr;
- }
+ return nullptr;
+ }
- inline TArrayRef<const TStringBuf> GetBestCodecs() const {
- return BestCodecs_;
- }
+ inline TArrayRef<const TStringBuf> GetBestCodecs() const {
+ return BestCodecs_;
+ }
private:
- void Add(TStringBuf name, TDecoderConstructor d, TEncoderConstructor e);
+ void Add(TStringBuf name, TDecoderConstructor d, TEncoderConstructor e);
- struct TCodec {
- TDecoderConstructor Decoder;
- TEncoderConstructor Encoder;
- };
+ struct TCodec {
+ TDecoderConstructor Decoder;
+ TEncoderConstructor Encoder;
+ };
TDeque<TString> Strings_;
- THashMap<TStringBuf, TCodec> Codecs_;
- TVector<TStringBuf> BestCodecs_;
+ THashMap<TStringBuf, TCodec> Codecs_;
+ TVector<TStringBuf> BestCodecs_;
};
namespace NHttp {
diff --git a/library/cpp/http/io/compression_ut.cpp b/library/cpp/http/io/compression_ut.cpp
index bde9de4c88..2f3d131f8c 100644
--- a/library/cpp/http/io/compression_ut.cpp
+++ b/library/cpp/http/io/compression_ut.cpp
@@ -1,5 +1,5 @@
#include "stream.h"
-#include "compression.h"
+#include "compression.h"
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/tests_data.h>
@@ -7,41 +7,41 @@
#include <util/stream/zlib.h>
#include <util/generic/hash_set.h>
-Y_UNIT_TEST_SUITE(THttpCompressionTest) {
- static const TString DATA = "I'm a teapot";
+Y_UNIT_TEST_SUITE(THttpCompressionTest) {
+ static const TString DATA = "I'm a teapot";
- Y_UNIT_TEST(TestGetBestCodecs) {
- UNIT_ASSERT(TCompressionCodecFactory::Instance().GetBestCodecs().size() > 0);
+ Y_UNIT_TEST(TestGetBestCodecs) {
+ UNIT_ASSERT(TCompressionCodecFactory::Instance().GetBestCodecs().size() > 0);
}
- Y_UNIT_TEST(TestEncoder) {
- TStringStream buffer;
+ Y_UNIT_TEST(TestEncoder) {
+ TStringStream buffer;
{
- auto encoder = TCompressionCodecFactory::Instance().FindEncoder("gzip");
- UNIT_ASSERT(encoder);
+ auto encoder = TCompressionCodecFactory::Instance().FindEncoder("gzip");
+ UNIT_ASSERT(encoder);
- auto encodedStream = (*encoder)(&buffer);
- encodedStream->Write(DATA);
+ auto encodedStream = (*encoder)(&buffer);
+ encodedStream->Write(DATA);
}
- TZLibDecompress decompressor(&buffer);
- UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA);
+ TZLibDecompress decompressor(&buffer);
+ UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA);
}
- Y_UNIT_TEST(TestDecoder) {
- TStringStream buffer;
+ Y_UNIT_TEST(TestDecoder) {
+ TStringStream buffer;
{
- TZLibCompress compressor(TZLibCompress::TParams(&buffer).SetType(ZLib::GZip));
- compressor.Write(DATA);
+ TZLibCompress compressor(TZLibCompress::TParams(&buffer).SetType(ZLib::GZip));
+ compressor.Write(DATA);
}
- auto decoder = TCompressionCodecFactory::Instance().FindDecoder("gzip");
- UNIT_ASSERT(decoder);
+ auto decoder = TCompressionCodecFactory::Instance().FindDecoder("gzip");
+ UNIT_ASSERT(decoder);
- auto decodedStream = (*decoder)(&buffer);
- UNIT_ASSERT_EQUAL(decodedStream->ReadAll(), DATA);
+ auto decodedStream = (*decoder)(&buffer);
+ UNIT_ASSERT_EQUAL(decodedStream->ReadAll(), DATA);
}
Y_UNIT_TEST(TestChooseBestCompressionScheme) {
@@ -57,4 +57,4 @@ Y_UNIT_TEST_SUITE(THttpCompressionTest) {
accepted.insert("*");
UNIT_ASSERT_VALUES_EQUAL("gzip", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
}
-} // THttpCompressionTest suite
+} // THttpCompressionTest suite
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp
index cc6c7e887b..6689be684f 100644
--- a/library/cpp/http/io/stream.cpp
+++ b/library/cpp/http/io/stream.cpp
@@ -1,11 +1,11 @@
#include "stream.h"
-
-#include "compression.h"
+
+#include "compression.h"
#include "chunk.h"
-#include <util/stream/buffered.h>
+#include <util/stream/buffered.h>
#include <util/stream/length.h>
-#include <util/stream/multi.h>
+#include <util/stream/multi.h>
#include <util/stream/null.h>
#include <util/stream/tee.h>
@@ -352,9 +352,9 @@ private:
}
}
- if (auto decoder = TCompressionCodecFactory::Instance().FindDecoder(p.LZipped)) {
+ if (auto decoder = TCompressionCodecFactory::Instance().FindDecoder(p.LZipped)) {
ContentEncoded_ = true;
- Input_ = Streams_.Add((*decoder)(Input_).Release());
+ Input_ = Streams_.Add((*decoder)(Input_).Release());
}
KeepAlive_ = p.KeepAlive;
@@ -427,7 +427,7 @@ bool THttpInput::AcceptEncoding(const TString& coding) const {
return Impl_->AcceptEncoding(coding);
}
-TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) const {
+TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) const {
return NHttp::ChooseBestCompressionScheme(
[this](const TString& coding) {
return AcceptEncoding(coding);
@@ -437,7 +437,7 @@ TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) c
}
TString THttpInput::BestCompressionScheme() const {
- return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs());
+ return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs());
}
bool THttpInput::GetContentLength(ui64& value) const noexcept {
@@ -504,7 +504,7 @@ public:
, Version_(1100)
, KeepAliveEnabled_(false)
, BodyEncodingEnabled_(true)
- , CompressionHeaderEnabled_(true)
+ , CompressionHeaderEnabled_(true)
, Finished_(false)
{
}
@@ -583,7 +583,7 @@ public:
return Headers_;
}
- inline void EnableCompression(TArrayRef<const TStringBuf> schemas) {
+ inline void EnableCompression(TArrayRef<const TStringBuf> schemas) {
ComprSchemas_ = schemas;
}
@@ -595,12 +595,12 @@ public:
BodyEncodingEnabled_ = enable;
}
- inline void EnableCompressionHeader(bool enable) {
- CompressionHeaderEnabled_ = enable;
- }
-
+ inline void EnableCompressionHeader(bool enable) {
+ CompressionHeaderEnabled_ = enable;
+ }
+
inline bool IsCompressionEnabled() const noexcept {
- return !ComprSchemas_.empty();
+ return !ComprSchemas_.empty();
}
inline bool IsKeepAliveEnabled() const noexcept {
@@ -611,10 +611,10 @@ public:
return BodyEncodingEnabled_;
}
- inline bool IsCompressionHeaderEnabled() const noexcept {
- return CompressionHeaderEnabled_;
- }
-
+ inline bool IsCompressionHeaderEnabled() const noexcept {
+ return CompressionHeaderEnabled_;
+ }
+
inline bool CanBeKeepAlive() const noexcept {
return SupportChunkedTransfer() && IsKeepAliveEnabled() && (Request_ ? Request_->IsKeepAlive() : true);
}
@@ -773,7 +773,7 @@ private:
if (IsHttpResponse()) {
if (Request_ && IsCompressionEnabled() && HasResponseBody()) {
- TString scheme = Request_->BestCompressionScheme(ComprSchemas_);
+ TString scheme = Request_->BestCompressionScheme(ComprSchemas_);
if (scheme != "identity") {
AddOrReplaceHeader(THttpInputHeader("Content-Encoding", scheme));
RemoveHeader("Content-Length");
@@ -794,12 +794,12 @@ private:
inline TString BuildAcceptEncoding() const {
TString ret;
- for (const auto& coding : ComprSchemas_) {
+ for (const auto& coding : ComprSchemas_) {
if (ret) {
ret += ", ";
}
- ret += coding;
+ ret += coding;
}
return ret;
@@ -807,7 +807,7 @@ private:
inline void RebuildStream() {
bool keepAlive = false;
- const TCompressionCodecFactory::TEncoderConstructor* encoder = nullptr;
+ const TCompressionCodecFactory::TEncoderConstructor* encoder = nullptr;
bool chunked = false;
bool haveContentLength = false;
@@ -818,7 +818,7 @@ private:
if (hl == TStringBuf("connection")) {
keepAlive = to_lower(header.Value()) == TStringBuf("keep-alive");
} else if (IsCompressionHeaderEnabled() && hl == TStringBuf("content-encoding")) {
- encoder = TCompressionCodecFactory::Instance().FindEncoder(to_lower(header.Value()));
+ encoder = TCompressionCodecFactory::Instance().FindEncoder(to_lower(header.Value()));
} else if (hl == TStringBuf("transfer-encoding")) {
chunked = to_lower(header.Value()) == TStringBuf("chunked");
} else if (hl == TStringBuf("content-length")) {
@@ -838,7 +838,7 @@ private:
Output_ = Streams_.Add(new TTeeOutput(Output_, &SizeCalculator_));
if (IsBodyEncodingEnabled() && encoder) {
- Output_ = Streams_.Add((*encoder)(Output_).Release());
+ Output_ = Streams_.Add((*encoder)(Output_).Release());
}
}
@@ -865,11 +865,11 @@ private:
THttpInput* Request_;
size_t Version_;
- TArrayRef<const TStringBuf> ComprSchemas_;
+ TArrayRef<const TStringBuf> ComprSchemas_;
bool KeepAliveEnabled_;
bool BodyEncodingEnabled_;
- bool CompressionHeaderEnabled_;
+ bool CompressionHeaderEnabled_;
bool Finished_;
@@ -911,15 +911,15 @@ const THttpHeaders& THttpOutput::SentHeaders() const noexcept {
void THttpOutput::EnableCompression(bool enable) {
if (enable) {
- EnableCompression(TCompressionCodecFactory::Instance().GetBestCodecs());
+ EnableCompression(TCompressionCodecFactory::Instance().GetBestCodecs());
} else {
- TArrayRef<TStringBuf> codings;
- EnableCompression(codings);
+ TArrayRef<TStringBuf> codings;
+ EnableCompression(codings);
}
}
-void THttpOutput::EnableCompression(TArrayRef<const TStringBuf> schemas) {
- Impl_->EnableCompression(schemas);
+void THttpOutput::EnableCompression(TArrayRef<const TStringBuf> schemas) {
+ Impl_->EnableCompression(schemas);
}
void THttpOutput::EnableKeepAlive(bool enable) {
@@ -930,10 +930,10 @@ void THttpOutput::EnableBodyEncoding(bool enable) {
Impl_->EnableBodyEncoding(enable);
}
-void THttpOutput::EnableCompressionHeader(bool enable) {
- Impl_->EnableCompressionHeader(enable);
-}
-
+void THttpOutput::EnableCompressionHeader(bool enable) {
+ Impl_->EnableCompressionHeader(enable);
+}
+
bool THttpOutput::IsKeepAliveEnabled() const noexcept {
return Impl_->IsKeepAliveEnabled();
}
@@ -946,10 +946,10 @@ bool THttpOutput::IsCompressionEnabled() const noexcept {
return Impl_->IsCompressionEnabled();
}
-bool THttpOutput::IsCompressionHeaderEnabled() const noexcept {
- return Impl_->IsCompressionHeaderEnabled();
-}
-
+bool THttpOutput::IsCompressionHeaderEnabled() const noexcept {
+ return Impl_->IsCompressionHeaderEnabled();
+}
+
bool THttpOutput::CanBeKeepAlive() const noexcept {
return Impl_->CanBeKeepAlive();
}
@@ -1000,6 +1000,6 @@ void SendMinimalHttpRequest(TSocket& s, const TStringBuf& host, const TStringBuf
output.Finish();
}
-TArrayRef<const TStringBuf> SupportedCodings() {
- return TCompressionCodecFactory::Instance().GetBestCodecs();
+TArrayRef<const TStringBuf> SupportedCodings() {
+ return TCompressionCodecFactory::Instance().GetBestCodecs();
}
diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h
index 43f7790399..78ca4fc814 100644
--- a/library/cpp/http/io/stream.h
+++ b/library/cpp/http/io/stream.h
@@ -71,7 +71,7 @@ public:
/// любые типы кодирования, выбирается gzip. В противном случае
/// из списка типов кодирования выбирается лучший из поддерживаемых сервером.
TString BestCompressionScheme() const;
- TString BestCompressionScheme(TArrayRef<const TStringBuf> codings) const;
+ TString BestCompressionScheme(TArrayRef<const TStringBuf> codings) const;
/// Если заголовки содержат Content-Length, возвращает true и
/// записывает значение из заголовка в value
@@ -110,7 +110,7 @@ public:
/// Устанавливает режим, при котором сервер выдает ответ в упакованном виде.
void EnableCompression(bool enable);
- void EnableCompression(TArrayRef<const TStringBuf> schemas);
+ void EnableCompression(TArrayRef<const TStringBuf> schemas);
/// Устанавливает режим, при котором соединение с сервером не завершается
/// после окончания транзакции.
@@ -120,10 +120,10 @@ public:
/// с заголовками Content-Encoding и Transfer-Encoding (включен по умолчанию)
void EnableBodyEncoding(bool enable);
- /// Устанавливает режим, при котором тело HTTP-ответа сжимается кодеком
- /// указанным в Content-Encoding (включен по умолчанию)
- void EnableCompressionHeader(bool enable);
-
+ /// Устанавливает режим, при котором тело HTTP-ответа сжимается кодеком
+ /// указанным в Content-Encoding (включен по умолчанию)
+ void EnableCompressionHeader(bool enable);
+
/// Проверяет, производится ли выдача ответов в упакованном виде.
bool IsCompressionEnabled() const noexcept;
@@ -134,10 +134,10 @@ public:
/// с заголовками Content-Encoding и Transfer-Encoding
bool IsBodyEncodingEnabled() const noexcept;
- /// Проверяет, сжимается ли тело HTTP-ответа кодеком
- /// указанным в Content-Encoding
- bool IsCompressionHeaderEnabled() const noexcept;
-
+ /// Проверяет, сжимается ли тело HTTP-ответа кодеком
+ /// указанным в Content-Encoding
+ bool IsCompressionHeaderEnabled() const noexcept;
+
/*
* is this connection can be really keep-alive
*/
@@ -173,6 +173,6 @@ unsigned ParseHttpRetCode(const TStringBuf& ret);
/// Отправляет HTTP-серверу запрос с минимумом необходимых заголовков.
void SendMinimalHttpRequest(TSocket& s, const TStringBuf& host, const TStringBuf& request, const TStringBuf& agent = "YandexSomething/1.0", const TStringBuf& from = "webadmin@yandex.ru");
-TArrayRef<const TStringBuf> SupportedCodings();
+TArrayRef<const TStringBuf> SupportedCodings();
/// @}
diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp
index 47060a3948..1ea35df675 100644
--- a/library/cpp/http/io/stream_ut.cpp
+++ b/library/cpp/http/io/stream_ut.cpp
@@ -14,7 +14,7 @@
#include <util/stream/zlib.h>
#include <util/stream/null.h>
-Y_UNIT_TEST_SUITE(THttpStreamTest) {
+Y_UNIT_TEST_SUITE(THttpStreamTest) {
class TTestHttpServer: public THttpServer::ICallBack {
class TRequest: public THttpClientRequestEx {
public:
@@ -443,7 +443,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
Y_UNIT_TEST(CodecsPriority) {
TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n");
- TVector<TStringBuf> codecs = {"br", "gzip"};
+ TVector<TStringBuf> codecs = {"br", "gzip"};
THttpInput i(&request);
TString result;
@@ -451,7 +451,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
THttpOutput httpOut(&out, &i);
httpOut.EnableKeepAlive(true);
- httpOut.EnableCompression(codecs);
+ 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"
@@ -466,7 +466,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
Y_UNIT_TEST(CodecsPriority2) {
TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n");
- TVector<TStringBuf> codecs = {"gzip", "br"};
+ TVector<TStringBuf> codecs = {"gzip", "br"};
THttpInput i(&request);
TString result;
@@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
THttpOutput httpOut(&out, &i);
httpOut.EnableKeepAlive(true);
- httpOut.EnableCompression(codecs);
+ 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"
@@ -665,27 +665,27 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
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");
- const TString data = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
-
- THttpInput httpInput(&request);
- TString result;
-
- {
- TStringOutput output(result);
- THttpOutput httpOutput(&output, &httpInput);
- httpOutput.EnableCompressionHeader(false);
- httpOutput << "HTTP/1.1 200 OK\r\n"
- "content-encoding: gzip\r\n"
- "\r\n" + data;
- httpOutput.Finish();
- }
-
- UNIT_ASSERT(result.Contains("content-encoding: gzip"));
- UNIT_ASSERT(result.Contains(data));
- }
-
+ Y_UNIT_TEST(TestHttpOutputDisableCompressionHeader) {
+ TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n");
+ const TString data = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
+
+ THttpInput httpInput(&request);
+ TString result;
+
+ {
+ TStringOutput output(result);
+ THttpOutput httpOutput(&output, &httpInput);
+ httpOutput.EnableCompressionHeader(false);
+ httpOutput << "HTTP/1.1 200 OK\r\n"
+ "content-encoding: gzip\r\n"
+ "\r\n" + data;
+ httpOutput.Finish();
+ }
+
+ UNIT_ASSERT(result.Contains("content-encoding: gzip"));
+ UNIT_ASSERT(result.Contains(data));
+ }
+
size_t DoTestHttpOutputSize(const TString& res, bool enableCompession) {
TTestHttpServer serverImpl(res);
TPortManager pm;
@@ -729,4 +729,4 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
UNIT_ASSERT_VALUES_EQUAL(res.size(), DoTestHttpOutputSize(res, false));
UNIT_ASSERT_VALUES_UNEQUAL(res.size(), DoTestHttpOutputSize(res, true));
}
-} // THttpStreamTest suite
+} // THttpStreamTest suite
diff --git a/library/cpp/http/io/ut/ya.make b/library/cpp/http/io/ut/ya.make
index fbdb56a03a..84f6949db3 100644
--- a/library/cpp/http/io/ut/ya.make
+++ b/library/cpp/http/io/ut/ya.make
@@ -8,8 +8,8 @@ PEERDIR(
SRCS(
chunk_ut.cpp
- compression_ut.cpp
- headers_ut.cpp
+ compression_ut.cpp
+ headers_ut.cpp
stream_ut.cpp
)
diff --git a/library/cpp/http/io/ya.make b/library/cpp/http/io/ya.make
index ed4f88a4b6..dcfbd79885 100644
--- a/library/cpp/http/io/ya.make
+++ b/library/cpp/http/io/ya.make
@@ -14,9 +14,9 @@ PEERDIR(
SRCS(
chunk.cpp
- compression.cpp
+ compression.cpp
headers.cpp
- stream.cpp
+ stream.cpp
)
END()
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 37e127ee8e..5fc8c82912 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -99,7 +99,7 @@ namespace NPrivate {
T Value;
};
- using value_type = T;
+ using value_type = T;
using iterator = TIterator;
using const_iterator = TIterator;
@@ -205,7 +205,7 @@ namespace NPrivate {
const TSteppedXRange* Parent_;
};
- using value_type = T;
+ using value_type = T;
using iterator = TIterator;
using const_iterator = TIterator;
diff --git a/util/network/poller.cpp b/util/network/poller.cpp
index 19cf23ca6a..7954d0e8b5 100644
--- a/util/network/poller.cpp
+++ b/util/network/poller.cpp
@@ -53,10 +53,10 @@ void TSocketPoller::WaitReadWrite(SOCKET sock, void* cookie) {
Impl_->Set(cookie, sock, CONT_POLL_READ | CONT_POLL_WRITE);
}
-void TSocketPoller::WaitRdhup(SOCKET sock, void* cookie) {
- Impl_->Set(cookie, sock, CONT_POLL_RDHUP);
-}
-
+void TSocketPoller::WaitRdhup(SOCKET sock, void* cookie) {
+ Impl_->Set(cookie, sock, CONT_POLL_RDHUP);
+}
+
void TSocketPoller::WaitReadOneShot(SOCKET sock, void* cookie) {
Impl_->Set(cookie, sock, CONT_POLL_READ | CONT_POLL_ONE_SHOT);
}
diff --git a/util/network/poller.h b/util/network/poller.h
index b1307e3d1d..8dccd73140 100644
--- a/util/network/poller.h
+++ b/util/network/poller.h
@@ -13,7 +13,7 @@ public:
void WaitRead(SOCKET sock, void* cookie);
void WaitWrite(SOCKET sock, void* cookie);
void WaitReadWrite(SOCKET sock, void* cookie);
- void WaitRdhup(SOCKET sock, void* cookie);
+ void WaitRdhup(SOCKET sock, void* cookie);
void WaitReadOneShot(SOCKET sock, void* cookie);
void WaitWriteOneShot(SOCKET sock, void* cookie);
diff --git a/util/network/poller_ut.cpp b/util/network/poller_ut.cpp
index 9324d52c9a..6df0dda8ec 100644
--- a/util/network/poller_ut.cpp
+++ b/util/network/poller_ut.cpp
@@ -3,7 +3,7 @@
#include "pair.h"
#include "poller.h"
-#include "pollerimpl.h"
+#include "pollerimpl.h"
Y_UNIT_TEST_SUITE(TSocketPollerTest) {
Y_UNIT_TEST(TestSimple) {
@@ -209,28 +209,28 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
poller.Unwait(sockets[1]);
}
}
-
-#if defined(HAVE_EPOLL_POLLER)
- Y_UNIT_TEST(TestRdhup) {
- SOCKET sockets[2];
- UNIT_ASSERT(SocketPair(sockets) == 0);
-
- TSocketHolder s1(sockets[0]);
- TSocketHolder s2(sockets[1]);
-
- char buf[1] = {0};
- UNIT_ASSERT_VALUES_EQUAL(1, send(s1, buf, 1, 0));
- shutdown(s1, SHUT_WR);
-
+
+#if defined(HAVE_EPOLL_POLLER)
+ Y_UNIT_TEST(TestRdhup) {
+ SOCKET sockets[2];
+ UNIT_ASSERT(SocketPair(sockets) == 0);
+
+ TSocketHolder s1(sockets[0]);
+ TSocketHolder s2(sockets[1]);
+
+ char buf[1] = {0};
+ UNIT_ASSERT_VALUES_EQUAL(1, send(s1, buf, 1, 0));
+ shutdown(s1, SHUT_WR);
+
using TPoller = TGenericPoller<TEpollPoller<TWithoutLocking>>;
- TPoller poller;
- poller.Set((void*)17, s2, CONT_POLL_RDHUP);
-
- TPoller::TEvent e;
- UNIT_ASSERT_VALUES_EQUAL(poller.WaitD(&e, 1, TDuration::Zero().ToDeadLine()), 1);
- UNIT_ASSERT_EQUAL(TPoller::ExtractStatus(&e), 0);
- UNIT_ASSERT_EQUAL(TPoller::ExtractFilter(&e), CONT_POLL_RDHUP);
- UNIT_ASSERT_EQUAL(TPoller::ExtractEvent(&e), (void*)17);
- }
-#endif
+ TPoller poller;
+ poller.Set((void*)17, s2, CONT_POLL_RDHUP);
+
+ TPoller::TEvent e;
+ UNIT_ASSERT_VALUES_EQUAL(poller.WaitD(&e, 1, TDuration::Zero().ToDeadLine()), 1);
+ UNIT_ASSERT_EQUAL(TPoller::ExtractStatus(&e), 0);
+ UNIT_ASSERT_EQUAL(TPoller::ExtractFilter(&e), CONT_POLL_RDHUP);
+ UNIT_ASSERT_EQUAL(TPoller::ExtractEvent(&e), (void*)17);
+ }
+#endif
}
diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h
index 25ece42701..e8c7e40fba 100644
--- a/util/network/pollerimpl.h
+++ b/util/network/pollerimpl.h
@@ -36,7 +36,7 @@ enum EContPoll {
CONT_POLL_RDHUP = 4,
CONT_POLL_ONE_SHOT = 8, // Disable after first event
CONT_POLL_MODIFY = 16, // Modify already added event
- CONT_POLL_EDGE_TRIGGERED = 32, // Notify only about new events
+ CONT_POLL_EDGE_TRIGGERED = 32, // Notify only about new events
CONT_POLL_BACKLOG_EMPTY = 64, // Backlog is empty (seen end of request, EAGAIN or truncated read)
};
@@ -245,10 +245,10 @@ public:
e.events |= EPOLLOUT;
}
- if (what & CONT_POLL_RDHUP) {
- e.events |= EPOLLRDHUP;
- }
-
+ if (what & CONT_POLL_RDHUP) {
+ e.events |= EPOLLRDHUP;
+ }
+
e.data.ptr = data;
if ((what & CONT_POLL_MODIFY) || epoll_ctl(Fd_, EPOLL_CTL_ADD, fd, &e) == -1) {
@@ -297,10 +297,10 @@ public:
ret |= CONT_POLL_WRITE;
}
- if (event->events & EPOLLRDHUP) {
- ret |= CONT_POLL_RDHUP;
- }
-
+ if (event->events & EPOLLRDHUP) {
+ ret |= CONT_POLL_RDHUP;
+ }
+
return ret;
}
@@ -495,11 +495,11 @@ public:
SOCKET* keysToDeleteEnd = keysToDeleteBegin;
#if defined(_msan_enabled_) // msan doesn't handle FD_ZERO and cause false positive BALANCER-1347
- memset(in, 0, sizeof(*in));
- memset(out, 0, sizeof(*out));
- memset(errFds, 0, sizeof(*errFds));
+ memset(in, 0, sizeof(*in));
+ memset(out, 0, sizeof(*out));
+ memset(errFds, 0, sizeof(*errFds));
#endif
-
+
FD_ZERO(in);
FD_ZERO(out);
FD_ZERO(errFds);
@@ -669,7 +669,7 @@ public:
static inline int ExtractFilter(const TEvent* event) noexcept {
if (TBase::ExtractStatus(event)) {
- return CONT_POLL_READ | CONT_POLL_WRITE | CONT_POLL_RDHUP;
+ return CONT_POLL_READ | CONT_POLL_WRITE | CONT_POLL_RDHUP;
}
return TBase::ExtractFilterImpl(event);
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 983b753dc2..60f4e9439f 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -267,20 +267,20 @@ public:
}
inline void Flush() {
- int ret = deflate(Z(), Z_SYNC_FLUSH);
-
- while ((ret == Z_OK || ret == Z_BUF_ERROR) && !Z()->avail_out) {
- FlushBuffer();
- ret = deflate(Z(), Z_SYNC_FLUSH);
- }
-
- if (ret != Z_OK && ret != Z_BUF_ERROR) {
- ythrow TZLibCompressorError() << "deflate flush error(" << GetErrMsg() << ")";
- }
-
- if (Z()->avail_out < TmpBufLen()) {
- FlushBuffer();
- }
+ int ret = deflate(Z(), Z_SYNC_FLUSH);
+
+ while ((ret == Z_OK || ret == Z_BUF_ERROR) && !Z()->avail_out) {
+ FlushBuffer();
+ ret = deflate(Z(), Z_SYNC_FLUSH);
+ }
+
+ if (ret != Z_OK && ret != Z_BUF_ERROR) {
+ ythrow TZLibCompressorError() << "deflate flush error(" << GetErrMsg() << ")";
+ }
+
+ if (Z()->avail_out < TmpBufLen()) {
+ FlushBuffer();
+ }
}
inline void FlushBuffer() {
@@ -300,7 +300,7 @@ public:
if (ret == Z_STREAM_END) {
Stream_->Write(TmpBuf(), TmpBufLen() - Z()->avail_out);
} else {
- ythrow TZLibCompressorError() << "deflate finish error(" << GetErrMsg() << ")";
+ ythrow TZLibCompressorError() << "deflate finish error(" << GetErrMsg() << ")";
}
}
@@ -339,7 +339,7 @@ size_t TZLibDecompress::DoRead(void* buf, size_t size) {
}
void TZLibCompress::Init(const TParams& params) {
- Y_ENSURE(params.BufLen >= 16, "ZLib buffer too small");
+ Y_ENSURE(params.BufLen >= 16, "ZLib buffer too small");
Impl_.Reset(new (params.BufLen) TImpl(params));
}
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index a03904fe3d..2290b4a9de 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -52,14 +52,14 @@ private:
};
Y_UNIT_TEST_SUITE(TZLibTest) {
- static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s";
- static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv";
+ static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s";
+ static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv";
Y_UNIT_TEST(Compress) {
TUnbufferedFileOutput o(ZDATA);
TZLibCompress c(&o, ZLib::ZLib);
- c.Write(DATA.data(), DATA.size());
+ c.Write(DATA.data(), DATA.size());
c.Finish();
o.Finish();
}
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
TUnbufferedFileInput i(ZDATA);
TZLibDecompress d(&i);
- UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
+ UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
}
}
@@ -96,10 +96,10 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
{
TUnbufferedFileOutput o(ZDATA);
TZLibCompress c1(&o, ZLib::ZLib);
- c1.Write(DATA.data(), DATA.size());
+ c1.Write(DATA.data(), DATA.size());
c1.Finish();
TZLibCompress c2(&o, ZLib::ZLib);
- c2.Write(DATA2.data(), DATA2.size());
+ c2.Write(DATA2.data(), DATA2.size());
c2.Finish();
o.Finish();
}
@@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
TUnbufferedFileInput i(ZDATA);
TZLibDecompress d(&i);
- UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2);
+ UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2);
}
}
@@ -132,10 +132,10 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
{
TUnbufferedFileOutput o(ZDATA);
TZLibCompress c1(&o, ZLib::ZLib);
- c1.Write(DATA.data(), DATA.size());
+ c1.Write(DATA.data(), DATA.size());
c1.Finish();
TZLibCompress c2(&o, ZLib::ZLib);
- c2.Write(DATA2.data(), DATA2.size());
+ c2.Write(DATA2.data(), DATA2.size());
c2.Finish();
o.Finish();
}
@@ -144,87 +144,87 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
TZLibDecompress d(&i);
d.SetAllowMultipleStreams(false);
- UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
+ UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
+ }
+ }
+
+ Y_UNIT_TEST(CompressFlush) {
+ TString data = "";
+
+ for (size_t i = 0; i < 32; ++i) {
+ TTempFile tmpFile(ZDATA);
+
+ TUnbufferedFileOutput output(ZDATA);
+ TZLibCompress compressor(&output, ZLib::ZLib);
+
+ compressor.Write(data.data(), data.size());
+ compressor.Flush();
+
+ {
+ TUnbufferedFileInput input(ZDATA);
+ TZLibDecompress decompressor(&input);
+
+ UNIT_ASSERT_EQUAL(decompressor.ReadAll(), data);
+ }
+
+ data += 'A' + i;
+ }
+ }
+
+ Y_UNIT_TEST(CompressEmptyFlush) {
+ TTempFile tmpFile(ZDATA);
+
+ TUnbufferedFileOutput output(ZDATA);
+ TZLibCompress compressor(&output, ZLib::ZLib);
+
+ TUnbufferedFileInput input(ZDATA);
+
+ compressor.Write(DATA.data(), DATA.size());
+ compressor.Flush();
+
+ {
+ TZLibDecompress decompressor(&input);
+ UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA);
+ }
+
+ for (size_t i = 0; i < 10; ++i) {
+ compressor.Flush();
+ }
+
+ UNIT_ASSERT_EQUAL(input.ReadAll(), "");
+ }
+
+ Y_UNIT_TEST(CompressFlushSmallBuffer) {
+ for (size_t bufferSize = 16; bufferSize < 32; ++bufferSize) {
+ TString firstData = "";
+
+ for (size_t firstDataSize = 0; firstDataSize < 16; ++firstDataSize) {
+ TString secondData = "";
+
+ for (size_t secondDataSize = 0; secondDataSize < 16; ++secondDataSize) {
+ TTempFile tmpFile(ZDATA);
+
+ TUnbufferedFileOutput output(ZDATA);
+ TZLibCompress compressor(TZLibCompress::TParams(&output).SetType(ZLib::ZLib).SetBufLen(bufferSize));
+
+ TUnbufferedFileInput input(ZDATA);
+ TZLibDecompress decompressor(&input);
+
+ compressor.Write(firstData.data(), firstData.size());
+ compressor.Flush();
+
+ UNIT_ASSERT_EQUAL(decompressor.ReadAll(), firstData);
+
+ compressor.Write(secondData.data(), secondData.size());
+ compressor.Flush();
+
+ UNIT_ASSERT_EQUAL(decompressor.ReadAll(), secondData);
+
+ secondData += 'A' + secondDataSize;
+ }
+
+ firstData += 'A' + firstDataSize;
+ }
}
}
-
- Y_UNIT_TEST(CompressFlush) {
- TString data = "";
-
- for (size_t i = 0; i < 32; ++i) {
- TTempFile tmpFile(ZDATA);
-
- TUnbufferedFileOutput output(ZDATA);
- TZLibCompress compressor(&output, ZLib::ZLib);
-
- compressor.Write(data.data(), data.size());
- compressor.Flush();
-
- {
- TUnbufferedFileInput input(ZDATA);
- TZLibDecompress decompressor(&input);
-
- UNIT_ASSERT_EQUAL(decompressor.ReadAll(), data);
- }
-
- data += 'A' + i;
- }
- }
-
- Y_UNIT_TEST(CompressEmptyFlush) {
- TTempFile tmpFile(ZDATA);
-
- TUnbufferedFileOutput output(ZDATA);
- TZLibCompress compressor(&output, ZLib::ZLib);
-
- TUnbufferedFileInput input(ZDATA);
-
- compressor.Write(DATA.data(), DATA.size());
- compressor.Flush();
-
- {
- TZLibDecompress decompressor(&input);
- UNIT_ASSERT_EQUAL(decompressor.ReadAll(), DATA);
- }
-
- for (size_t i = 0; i < 10; ++i) {
- compressor.Flush();
- }
-
- UNIT_ASSERT_EQUAL(input.ReadAll(), "");
- }
-
- Y_UNIT_TEST(CompressFlushSmallBuffer) {
- for (size_t bufferSize = 16; bufferSize < 32; ++bufferSize) {
- TString firstData = "";
-
- for (size_t firstDataSize = 0; firstDataSize < 16; ++firstDataSize) {
- TString secondData = "";
-
- for (size_t secondDataSize = 0; secondDataSize < 16; ++secondDataSize) {
- TTempFile tmpFile(ZDATA);
-
- TUnbufferedFileOutput output(ZDATA);
- TZLibCompress compressor(TZLibCompress::TParams(&output).SetType(ZLib::ZLib).SetBufLen(bufferSize));
-
- TUnbufferedFileInput input(ZDATA);
- TZLibDecompress decompressor(&input);
-
- compressor.Write(firstData.data(), firstData.size());
- compressor.Flush();
-
- UNIT_ASSERT_EQUAL(decompressor.ReadAll(), firstData);
-
- compressor.Write(secondData.data(), secondData.size());
- compressor.Flush();
-
- UNIT_ASSERT_EQUAL(decompressor.ReadAll(), secondData);
-
- secondData += 'A' + secondDataSize;
- }
-
- firstData += 'A' + firstDataSize;
- }
- }
- }
}