diff options
author | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 23:39:40 +0300 |
---|---|---|
committer | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-09 23:57:14 +0300 |
commit | e601ca03f859335d57ecff2e5aa6af234b6052ed (patch) | |
tree | de519a847e58a1b3993fcbfe05ff44cc946a3e24 /library/cpp/messagebus | |
parent | bbf2b6878af3854815a2c0ecb07a687071787639 (diff) | |
download | ydb-e601ca03f859335d57ecff2e5aa6af234b6052ed.tar.gz |
Y_VERIFY->Y_ABORT_UNLESS at ^l
https://clubs.at.yandex-team.ru/arcadia/29404
Diffstat (limited to 'library/cpp/messagebus')
53 files changed, 184 insertions, 184 deletions
diff --git a/library/cpp/messagebus/actor/actor.h b/library/cpp/messagebus/actor/actor.h index 9b8f20298a2..a7e706cf214 100644 --- a/library/cpp/messagebus/actor/actor.h +++ b/library/cpp/messagebus/actor/actor.h @@ -82,14 +82,14 @@ namespace NActor { void ScheduleHereAtMostOnce() { if (Tasks.AddTask()) { bool fetched = Tasks.FetchTask(); - Y_VERIFY(fetched, "happens"); + Y_ABORT_UNLESS(fetched, "happens"); DoAct(); // if someone added more tasks, schedule them if (Tasks.FetchTask()) { bool added = Tasks.AddTask(); - Y_VERIFY(!added, "happens"); + Y_ABORT_UNLESS(!added, "happens"); EnqueueWork(); } } diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 0c095b16778..70233799e3c 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -178,7 +178,7 @@ void TExecutor::Init() { AtomicSet(ExitWorkers, 0); - Y_VERIFY(Config.WorkerCount > 0); + Y_ABORT_UNLESS(Config.WorkerCount > 0); for (size_t i = 0; i < Config.WorkerCount; i++) { WorkerThreads.push_back(new TExecutorWorker(this)); @@ -215,7 +215,7 @@ void TExecutor::EnqueueWork(TArrayRef<IWorkItem* const> wis) { return; if (Y_UNLIKELY(AtomicGet(ExitWorkers) != 0)) { - Y_VERIFY(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); + Y_ABORT_UNLESS(WorkItems.Empty(), "executor %s: cannot add tasks after queue shutdown", Config.Name); } TWhatThreadDoesPushPop pp("executor: EnqueueWork"); @@ -319,7 +319,7 @@ void TExecutor::ProcessWorkQueueHere() { } void TExecutor::RunWorker() { - Y_VERIFY(!ThreadCurrentExecutor, "state check"); + Y_ABORT_UNLESS(!ThreadCurrentExecutor, "state check"); ThreadCurrentExecutor = this; SetCurrentThreadName("wrkr"); diff --git a/library/cpp/messagebus/actor/queue_for_actor.h b/library/cpp/messagebus/actor/queue_for_actor.h index 40fa536b825..99d0d4c89e8 100644 --- a/library/cpp/messagebus/actor/queue_for_actor.h +++ b/library/cpp/messagebus/actor/queue_for_actor.h @@ -21,7 +21,7 @@ namespace NActor { public: ~TQueueForActor() { - Y_VERIFY(Queue.IsEmpty()); + Y_ABORT_UNLESS(Queue.IsEmpty()); } bool IsEmpty() { diff --git a/library/cpp/messagebus/async_result.h b/library/cpp/messagebus/async_result.h index d24dde284a3..be8c9c1f95b 100644 --- a/library/cpp/messagebus/async_result.h +++ b/library/cpp/messagebus/async_result.h @@ -24,7 +24,7 @@ private: public: void SetResult(const T& result) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(!Result, "cannot set result twice"); + Y_ABORT_UNLESS(!Result, "cannot set result twice"); Result = result; CondVar.BroadCast(); diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp index 962ac538e27..4660711a0ca 100644 --- a/library/cpp/messagebus/config/netaddr.cpp +++ b/library/cpp/messagebus/config/netaddr.cpp @@ -66,7 +66,7 @@ namespace NBus { TNetAddr::TNetAddr(TAutoPtr<IRemoteAddr> addr) : Ptr(addr) { - Y_VERIFY(!!Ptr); + Y_ABORT_UNLESS(!!Ptr); } namespace { diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index fbbbb106c9d..3188bf62e26 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -31,12 +31,12 @@ static int ParseToSForMessageBus(const char* option) { TStringBuf str(option); if (str.StartsWith("0x")) { str = str.Tail(2); - Y_VERIFY(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); + Y_ABORT_UNLESS(str.length() == 2, "ToS must be a number between 0x00 and 0xFF"); tos = String2Byte(str.data()); } else { tos = FromString<int>(option); } - Y_VERIFY(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); + Y_ABORT_UNLESS(tos >= 0 && tos <= 255, "ToS must be between 0x00 and 0xFF"); return tos; } diff --git a/library/cpp/messagebus/duration_histogram.cpp b/library/cpp/messagebus/duration_histogram.cpp index 32a0001d414..ac3783b6005 100644 --- a/library/cpp/messagebus/duration_histogram.cpp +++ b/library/cpp/messagebus/duration_histogram.cpp @@ -48,7 +48,7 @@ namespace { } TString TDurationHistogram::LabelBefore(unsigned i) { - Y_VERIFY(i < Buckets); + Y_ABORT_UNLESS(i < Buckets); TDuration d = Singleton<TMarks>()->Marks[i]; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index 4240a5cd96c..9a9d90508d5 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -280,7 +280,7 @@ TEventLoop::TImpl::TImpl(const char* name) void TEventLoop::TImpl::Run() { bool res = AtomicCas(&RunningState, EVENT_LOOP_RUNNING, EVENT_LOOP_CREATED); - Y_VERIFY(res, "Invalid mbus event loop state"); + Y_ABORT_UNLESS(res, "Invalid mbus event loop state"); if (!!Name) { SetCurrentThreadName(Name); @@ -308,7 +308,7 @@ void TEventLoop::TImpl::Run() { SOCKET socket = -1; while (SocketsToRemove.Dequeue(&socket)) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.erase(socket) == 1, "must be removed once"); + Y_ABORT_UNLESS(Data.erase(socket) == 1, "must be removed once"); } } @@ -324,7 +324,7 @@ void TEventLoop::TImpl::Run() { res = AtomicCas(&RunningState, EVENT_LOOP_STOPPED, EVENT_LOOP_RUNNING); - Y_VERIFY(res); + Y_ABORT_UNLESS(res); StoppedEvent.Signal(); } @@ -340,13 +340,13 @@ void TEventLoop::TImpl::Stop() { } TChannelPtr TEventLoop::TImpl::Register(TSocket socket, TEventHandlerPtr eventHandler, void* cookie) { - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_ABORT_UNLESS(socket != INVALID_SOCKET, "must be a valid socket"); TChannelPtr channel = new TChannel(new TChannel::TImpl(this, socket, eventHandler, cookie)); TGuard<TMutex> guard(Mutex); - Y_VERIFY(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); + Y_ABORT_UNLESS(Data.insert(std::make_pair(socket, channel)).second, "must not be already inserted"); return channel; } diff --git a/library/cpp/messagebus/futex_like.cpp b/library/cpp/messagebus/futex_like.cpp index 7f965126db8..71998065a64 100644 --- a/library/cpp/messagebus/futex_like.cpp +++ b/library/cpp/messagebus/futex_like.cpp @@ -31,7 +31,7 @@ void TFutexLike::Wake(size_t count) { count = Max<int>(); } int r = futex(&Value, FUTEX_WAKE, count, nullptr, nullptr, 0); - Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno)); + Y_ABORT_UNLESS(r >= 0, "futex_wake failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (count == 1) { @@ -45,7 +45,7 @@ void TFutexLike::Wake(size_t count) { void TFutexLike::Wait(int expected) { #ifdef _linux_ int r = futex(&Value, FUTEX_WAIT, expected, nullptr, nullptr, 0); - Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); + Y_ABORT_UNLESS(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno)); #else TGuard<TMutex> guard(Mutex); if (expected == Get()) { diff --git a/library/cpp/messagebus/handler_impl.h b/library/cpp/messagebus/handler_impl.h index 6593f04cc37..ae4d8234009 100644 --- a/library/cpp/messagebus/handler_impl.h +++ b/library/cpp/messagebus/handler_impl.h @@ -15,8 +15,8 @@ namespace NBus { } inline void TOnMessageContext::AckMessage(TBusIdentity& ident) { - Y_VERIFY(Ident.LocalFlags == NPrivate::MESSAGE_IN_WORK); - Y_VERIFY(ident.LocalFlags == 0); + Y_ABORT_UNLESS(Ident.LocalFlags == NPrivate::MESSAGE_IN_WORK); + Y_ABORT_UNLESS(ident.LocalFlags == 0); Ident.Swap(ident); } diff --git a/library/cpp/messagebus/locator.cpp b/library/cpp/messagebus/locator.cpp index e38a35c426f..e49716f1662 100644 --- a/library/cpp/messagebus/locator.cpp +++ b/library/cpp/messagebus/locator.cpp @@ -250,7 +250,7 @@ namespace NBus { int TBusLocator::LocateAll(TBusService service, TBusKey key, TVector<TNetAddr>& addrs) { TGuard<TMutex> G(Lock); - Y_VERIFY(addrs.empty(), "Non emtpy addresses"); + Y_ABORT_UNLESS(addrs.empty(), "Non emtpy addresses"); TServiceId serviceId = GetServiceId(service); TItems::const_iterator it; @@ -361,7 +361,7 @@ namespace NBus { int TBusLocator::LocateKeys(TBusService service, TBusKeyVec& keys, bool onlyLocal) { TGuard<TMutex> G(Lock); - Y_VERIFY(keys.empty(), "Non empty keys"); + Y_ABORT_UNLESS(keys.empty(), "Non empty keys"); TServiceId serviceId = GetServiceId(service); TItems::const_iterator it; diff --git a/library/cpp/messagebus/message.cpp b/library/cpp/messagebus/message.cpp index 20784860f32..ac8caa5c56c 100644 --- a/library/cpp/messagebus/message.cpp +++ b/library/cpp/messagebus/message.cpp @@ -23,10 +23,10 @@ namespace NBus { TBusIdentity::~TBusIdentity() { // TODO: print local flags #ifndef NDEBUG - Y_VERIFY(LocalFlags == 0, "local flags must be zero at this point; message type is %s", + Y_ABORT_UNLESS(LocalFlags == 0, "local flags must be zero at this point; message type is %s", MessageType.value_or("unknown").c_str()); #else - Y_VERIFY(LocalFlags == 0, "local flags must be zero at this point"); + Y_ABORT_UNLESS(LocalFlags == 0, "local flags must be zero at this point"); #endif } @@ -47,8 +47,8 @@ namespace NBus { } void TBusIdentity::Unpack(const char* src) { - Y_VERIFY(LocalFlags == 0); - Y_VERIFY(!Connection); + Y_ABORT_UNLESS(LocalFlags == 0); + Y_ABORT_UNLESS(!Connection); memcpy(this, src, sizeof(TBusIdentity)); } @@ -88,7 +88,7 @@ namespace NBus { TBusMessage::~TBusMessage() { #ifndef NDEBUG - Y_VERIFY(GetHeader()->Id != YBUS_KEYINVALID, "must not be invalid key, message type: %d, ", int(Type)); + Y_ABORT_UNLESS(GetHeader()->Id != YBUS_KEYINVALID, "must not be invalid key, message type: %d, ", int(Type)); GetHeader()->Id = YBUS_KEYINVALID; Data = (void*)17; CheckClean(); diff --git a/library/cpp/messagebus/message.h b/library/cpp/messagebus/message.h index 005ca10c652..2027f249830 100644 --- a/library/cpp/messagebus/message.h +++ b/library/cpp/messagebus/message.h @@ -93,7 +93,7 @@ namespace NBus { void SetMessageType(const std::type_info& messageTypeInfo) { #ifndef NDEBUG - Y_VERIFY(!MessageType, "state check"); + Y_ABORT_UNLESS(!MessageType, "state check"); MessageType = TypeName(messageTypeInfo); #else Y_UNUSED(messageTypeInfo); diff --git a/library/cpp/messagebus/message_status_counter.cpp b/library/cpp/messagebus/message_status_counter.cpp index 891c8f5bb2b..3d3f3c344ea 100644 --- a/library/cpp/messagebus/message_status_counter.cpp +++ b/library/cpp/messagebus/message_status_counter.cpp @@ -28,7 +28,7 @@ TString TMessageStatusCounter::PrintToString() const { bool hasZeros = false; for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_ABORT_UNLESS(Counts[i] == 0); continue; } if (Counts[i] != 0) { @@ -59,7 +59,7 @@ void TMessageStatusCounter::FillErrorsProtobuf(TConnectionStatusMonRecord* statu status->clear_errorcountbystatus(); for (size_t i = 0; i < MESSAGE_STATUS_COUNT; ++i) { if (i == MESSAGE_OK) { - Y_VERIFY(Counts[i] == 0); + Y_ABORT_UNLESS(Counts[i] == 0); continue; } if (Counts[i] != 0) { diff --git a/library/cpp/messagebus/messqueue.cpp b/library/cpp/messagebus/messqueue.cpp index 3474d62705f..85baa3c383c 100644 --- a/library/cpp/messagebus/messqueue.cpp +++ b/library/cpp/messagebus/messqueue.cpp @@ -169,7 +169,7 @@ void TBusMessageQueue::Add(TIntrusivePtr<TBusSessionImpl> session) { void TBusMessageQueue::Remove(TBusSession* session) { TGuard<TMutex> scope(Lock); TList<TIntrusivePtr<TBusSessionImpl>>::iterator it = std::find(Sessions.begin(), Sessions.end(), session); - Y_VERIFY(it != Sessions.end(), "do not destroy session twice"); + Y_ABORT_UNLESS(it != Sessions.end(), "do not destroy session twice"); Sessions.erase(it); } @@ -185,7 +185,7 @@ void TBusMessageQueue::DestroyAllSessions() { } for (auto& session : sessions) { - Y_VERIFY(session->IsDown(), "Session must be shut down prior to queue shutdown"); + Y_ABORT_UNLESS(session->IsDown(), "Session must be shut down prior to queue shutdown"); } } diff --git a/library/cpp/messagebus/misc/test_sync.h b/library/cpp/messagebus/misc/test_sync.h index be3f4f20b85..07dde1dfcd2 100644 --- a/library/cpp/messagebus/misc/test_sync.h +++ b/library/cpp/messagebus/misc/test_sync.h @@ -32,7 +32,7 @@ public: void WaitFor(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_ABORT_UNLESS(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -42,7 +42,7 @@ public: void WaitForAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current <= n, "too late, waiting for %d, already %d", n, Current); + Y_ABORT_UNLESS(Current <= n, "too late, waiting for %d, already %d", n, Current); while (n > Current) { CondVar.WaitI(Mutex); @@ -55,7 +55,7 @@ public: void CheckAndIncrement(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_ABORT_UNLESS(Current == n, "must be %d, currently %d", n, Current); DoInc(); CondVar.BroadCast(); @@ -64,7 +64,7 @@ public: void Check(unsigned n) { TGuard<TMutex> guard(Mutex); - Y_VERIFY(Current == n, "must be %d, currently %d", n, Current); + Y_ABORT_UNLESS(Current == n, "must be %d, currently %d", n, Current); } private: diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp index 304bedae5ac..a4afafa94ee 100644 --- a/library/cpp/messagebus/network.cpp +++ b/library/cpp/messagebus/network.cpp @@ -11,7 +11,7 @@ using namespace NBus::NPrivate; namespace { TBindResult BindOnPortProto(int port, int af, bool reusePort) { - Y_VERIFY(af == AF_INET || af == AF_INET6, "wrong af"); + Y_ABORT_UNLESS(af == AF_INET || af == AF_INET6, "wrong af"); SOCKET fd = ::socket(af, SOCK_STREAM, 0); if (fd == INVALID_SOCKET) { @@ -82,7 +82,7 @@ namespace { } std::pair<unsigned, TVector<TBindResult>> AggregateBindResults(TBindResult&& r1, TBindResult&& r2) { - Y_VERIFY(r1.Addr.GetPort() == r2.Addr.GetPort(), "internal"); + Y_ABORT_UNLESS(r1.Addr.GetPort() == r2.Addr.GetPort(), "internal"); std::pair<unsigned, TVector<TBindResult>> r; r.second.reserve(2); @@ -138,7 +138,7 @@ ssize_t NBus::NPrivate::SocketSend(SOCKET s, TArrayRef<const char> data) { #endif ssize_t r = ::send(s, data.data(), data.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_ABORT_UNLESS(LastSystemError() != EBADF, "bad fd"); } return r; } @@ -150,7 +150,7 @@ ssize_t NBus::NPrivate::SocketRecv(SOCKET s, TArrayRef<char> buffer) { #endif ssize_t r = ::recv(s, buffer.data(), buffer.size(), flags); if (r < 0) { - Y_VERIFY(LastSystemError() != EBADF, "bad fd"); + Y_ABORT_UNLESS(LastSystemError() != EBADF, "bad fd"); } return r; } diff --git a/library/cpp/messagebus/nondestroying_holder.h b/library/cpp/messagebus/nondestroying_holder.h index f4725d696f7..bd56e5335c7 100644 --- a/library/cpp/messagebus/nondestroying_holder.h +++ b/library/cpp/messagebus/nondestroying_holder.h @@ -16,7 +16,7 @@ public: } ~TNonDestroyingHolder() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_ABORT_UNLESS(!*this, "stored object must be explicitly released"); } }; @@ -34,6 +34,6 @@ public: } inline ~TNonDestroyingAutoPtr() { - Y_VERIFY(!*this, "stored object must be explicitly released"); + Y_ABORT_UNLESS(!*this, "stored object must be explicitly released"); } }; diff --git a/library/cpp/messagebus/oldmodule/module.cpp b/library/cpp/messagebus/oldmodule/module.cpp index 24bd778799f..4ec37a4d53f 100644 --- a/library/cpp/messagebus/oldmodule/module.cpp +++ b/library/cpp/messagebus/oldmodule/module.cpp @@ -143,14 +143,14 @@ namespace NBus { ~TBusModuleImpl() override { // Shutdown cannot be called from destructor, // because module has virtual methods. - Y_VERIFY(State != RUNNING, "if running, must explicitly call Shutdown() before destructor"); + Y_ABORT_UNLESS(State != RUNNING, "if running, must explicitly call Shutdown() before destructor"); Scheduler.Stop(); while (!Jobs.empty()) { DestroyJob(Jobs.front()); } - Y_VERIFY(JobCount == 0, "state check"); + Y_ABORT_UNLESS(JobCount == 0, "state check"); } void OnMessageReceived(TAutoPtr<TBusMessage> msg, TOnMessageContext&); @@ -336,7 +336,7 @@ namespace NBus { } TNetAddr TBusJob::GetPeerAddrNetAddr() const { - Y_VERIFY(!!OnMessageContext); + Y_ABORT_UNLESS(!!OnMessageContext); return OnMessageContext.GetPeerAddrNetAddr(); } @@ -452,7 +452,7 @@ namespace NBus { } } - Y_VERIFY(!(Pending.size() == 0 && Handler == nullptr && Status == MESSAGE_OK && !ReplySent), + Y_ABORT_UNLESS(!(Pending.size() == 0 && Handler == nullptr && Status == MESSAGE_OK && !ReplySent), "Handler returned NULL without Cancel() or SendReply() for message=%016" PRIx64 " type=%d", Message->GetHeader()->Id, Message->GetHeader()->Type); @@ -542,7 +542,7 @@ namespace NBus { void TBusJob::SendReply(TBusMessageAutoPtr reply) { CheckThreadCurrentJob(); - Y_VERIFY(!ReplySent, "cannot call SendReply twice"); + Y_ABORT_UNLESS(!ReplySent, "cannot call SendReply twice"); ReplySent = true; if (!OnMessageContext) return; @@ -581,8 +581,8 @@ namespace NBus { void TBusJob::Sleep(int milliSeconds) { CheckThreadCurrentJob(); - Y_VERIFY(Pending.empty(), "sleep is not allowed when there are pending job"); - Y_VERIFY(SleepUntil == 0, "must not override sleep"); + Y_ABORT_UNLESS(Pending.empty(), "sleep is not allowed when there are pending job"); + Y_ABORT_UNLESS(SleepUntil == 0, "must not override sleep"); SleepUntil = Now() + milliSeconds; } @@ -665,8 +665,8 @@ namespace NBus { } bool TBusModule::StartInput() { - Y_VERIFY(Impl->State == TBusModuleImpl::CREATED, "state check"); - Y_VERIFY(!!Impl->Queue, "state check"); + Y_ABORT_UNLESS(Impl->State == TBusModuleImpl::CREATED, "state check"); + Y_ABORT_UNLESS(!!Impl->Queue, "state check"); Impl->State = TBusModuleImpl::RUNNING; Y_ASSERT(!Impl->ExternalSession); @@ -774,7 +774,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { { TWhatThreadDoesAcquireGuard<TMutex> G(Lock, "modules: acquiring lock for DestroyJob"); int jobCount = AtomicDecrement(JobCount); - Y_VERIFY(jobCount >= 0, "decremented too much"); + Y_ABORT_UNLESS(jobCount >= 0, "decremented too much"); Jobs.erase(job->JobStorageIterator); if (AtomicGet(State) == STOPPED) { @@ -789,7 +789,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { void TBusModuleImpl::OnMessageReceived(TAutoPtr<TBusMessage> msg0, TOnMessageContext& context) { TBusMessage* msg = !!msg0 ? msg0.Get() : context.GetMessage(); - Y_VERIFY(!!msg); + Y_ABORT_UNLESS(!!msg); THolder<TJobRunner> jobRunner(new TJobRunner(Module->CreateJobInstance(msg))); jobRunner->Job->MessageHolder.Reset(msg0.Release()); @@ -834,8 +834,8 @@ void TBusModuleImpl::Shutdown() { } EMessageStatus TBusModule::StartJob(TAutoPtr<TBusMessage> message) { - Y_VERIFY(Impl->State == TBusModuleImpl::RUNNING); - Y_VERIFY(!!Impl->Queue); + Y_ABORT_UNLESS(Impl->State == TBusModuleImpl::RUNNING); + Y_ABORT_UNLESS(!!Impl->Queue); if ((unsigned)AtomicGet(Impl->JobCount) >= Impl->ModuleConfig.StarterMaxInFlight) { return MESSAGE_BUSY; diff --git a/library/cpp/messagebus/protobuf/ybusbuf.cpp b/library/cpp/messagebus/protobuf/ybusbuf.cpp index 63415b3737f..7212e59590a 100644 --- a/library/cpp/messagebus/protobuf/ybusbuf.cpp +++ b/library/cpp/messagebus/protobuf/ybusbuf.cpp @@ -58,7 +58,7 @@ void TBusBufferProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { data.Reserve(data.Size() + size); char* after = (char*)bmess->GetRecord()->SerializeWithCachedSizesToArray((ui8*)data.Pos()); - Y_VERIFY(after - data.Pos() == size); + Y_ABORT_UNLESS(after - data.Pos() == size); data.Advance(size); } diff --git a/library/cpp/messagebus/rain_check/core/coro_stack.cpp b/library/cpp/messagebus/rain_check/core/coro_stack.cpp index 83b984ca6e9..96ab66865c5 100644 --- a/library/cpp/messagebus/rain_check/core/coro_stack.cpp +++ b/library/cpp/messagebus/rain_check/core/coro_stack.cpp @@ -12,8 +12,8 @@ using namespace NRainCheck::NPrivate; TCoroStack::TCoroStack(size_t size) : SizeValue(size) { - Y_VERIFY(size % sizeof(ui32) == 0); - Y_VERIFY(size >= 0x1000); + Y_ABORT_UNLESS(size % sizeof(ui32) == 0); + Y_ABORT_UNLESS(size >= 0x1000); DataHolder.Reset(malloc(size)); diff --git a/library/cpp/messagebus/rain_check/core/simple_ut.cpp b/library/cpp/messagebus/rain_check/core/simple_ut.cpp index d4545e05aa1..d0afaf19faa 100644 --- a/library/cpp/messagebus/rain_check/core/simple_ut.cpp +++ b/library/cpp/messagebus/rain_check/core/simple_ut.cpp @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(RainCheckSimple) { } void SleepCompletionCallback(TSubtaskCompletion* completion) { - Y_VERIFY(completion == &SleepCompletion); + Y_ABORT_UNLESS(completion == &SleepCompletion); TestSync->CheckAndIncrement(1); Env->SleepService.Sleep(&SleepCompletion, TDuration::MilliSeconds(1)); diff --git a/library/cpp/messagebus/rain_check/core/task.cpp b/library/cpp/messagebus/rain_check/core/task.cpp index a098437d534..d8aeefac25c 100644 --- a/library/cpp/messagebus/rain_check/core/task.cpp +++ b/library/cpp/messagebus/rain_check/core/task.cpp @@ -199,7 +199,7 @@ void TTaskRunnerBase::AssertInThisThread() const { } TTaskRunnerBase* TTaskRunnerBase::CurrentTask() { - Y_VERIFY(!!ThreadCurrentTask); + Y_ABORT_UNLESS(!!ThreadCurrentTask); return ThreadCurrentTask; } diff --git a/library/cpp/messagebus/rain_check/http/client.cpp b/library/cpp/messagebus/rain_check/http/client.cpp index 5ef5ceeece2..7ac5034e910 100644 --- a/library/cpp/messagebus/rain_check/http/client.cpp +++ b/library/cpp/messagebus/rain_check/http/client.cpp @@ -19,7 +19,7 @@ namespace NRainCheck { THttpCallback(NRainCheck::THttpFuture* future) : Future(future) { - Y_VERIFY(!!future, "future is NULL"); + Y_ABORT_UNLESS(!!future, "future is NULL"); } void OnRecv(NNeh::THandle& handle) override { @@ -57,15 +57,15 @@ namespace NRainCheck { : GetProtocol(NNeh::ProtocolFactory()->Protocol("http")) , FullProtocol(NNeh::ProtocolFactory()->Protocol("full")) { - Y_VERIFY(!!GetProtocol, "GET protocol is NULL."); - Y_VERIFY(!!FullProtocol, "POST protocol is NULL."); + Y_ABORT_UNLESS(!!GetProtocol, "GET protocol is NULL."); + Y_ABORT_UNLESS(!!FullProtocol, "POST protocol is NULL."); } THttpClientService::~THttpClientService() { } void THttpClientService::SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future) { - Y_VERIFY(!!future, "future is NULL."); + Y_ABORT_UNLESS(!!future, "future is NULL."); TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask(); future->SetRunning(current); @@ -88,7 +88,7 @@ namespace NRainCheck { } void THttpClientService::Send(const TString& request, THttpFuture* future) { - Y_VERIFY(!!future, "future is NULL."); + Y_ABORT_UNLESS(!!future, "future is NULL."); TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask(); future->SetRunning(current); diff --git a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp index 1b3618558b8..35bb7abd8e3 100644 --- a/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp +++ b/library/cpp/messagebus/rain_check/messagebus/messagebus_client_ut.cpp @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); + Y_ABORT_UNLESS(Requests[i]->GetStatus() == MESSAGE_OK); VerifyDynamicCast<TExampleResponse*>(Requests[i]->GetResponse()); } Env->TestSync.CheckAndIncrement(0); @@ -124,8 +124,8 @@ Y_UNIT_TEST_SUITE(RainCheckMessageBusClient) { TContinueFunc GotReplies() { for (unsigned i = 0; i < Requests.size(); ++i) { - Y_VERIFY(Requests[i]->GetStatus() == MESSAGE_OK); - Y_VERIFY(!Requests[i]->GetResponse()); + Y_ABORT_UNLESS(Requests[i]->GetStatus() == MESSAGE_OK); + Y_ABORT_UNLESS(!Requests[i]->GetResponse()); } Env->TestSync.WaitForAndIncrement(2); return nullptr; diff --git a/library/cpp/messagebus/rain_check/test/helper/misc.cpp b/library/cpp/messagebus/rain_check/test/helper/misc.cpp index c0fcb272523..d940d68a4b0 100644 --- a/library/cpp/messagebus/rain_check/test/helper/misc.cpp +++ b/library/cpp/messagebus/rain_check/test/helper/misc.cpp @@ -5,7 +5,7 @@ using namespace NRainCheck; void TSpawnNopTasksCoroTask::Run() { - Y_VERIFY(Count <= Completion.size()); + Y_ABORT_UNLESS(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopCoroTask>(Env, &Completion[i], ""); } @@ -14,7 +14,7 @@ void TSpawnNopTasksCoroTask::Run() { } TContinueFunc TSpawnNopTasksSimpleTask::Start() { - Y_VERIFY(Count <= Completion.size()); + Y_ABORT_UNLESS(Count <= Completion.size()); for (unsigned i = 0; i < Count; ++i) { SpawnSubtask<TNopSimpleTask>(Env, &Completion[i], ""); } diff --git a/library/cpp/messagebus/remote_client_connection.cpp b/library/cpp/messagebus/remote_client_connection.cpp index 8c7a6db3a8c..30a7fc25fba 100644 --- a/library/cpp/messagebus/remote_client_connection.cpp +++ b/library/cpp/messagebus/remote_client_connection.cpp @@ -20,7 +20,7 @@ TRemoteClientConnection::TRemoteClientConnection(TRemoteClientSessionPtr session : TRemoteConnection(session.Get(), id, addr) , ClientHandler(GetSession()->ClientHandler) { - Y_VERIFY(addr.GetPort() > 0, "must connect to non-zero port"); + Y_ABORT_UNLESS(addr.GetPort() > 0, "must connect to non-zero port"); ScheduleWrite(); } @@ -35,7 +35,7 @@ TBusMessage* TRemoteClientConnection::PopAck(TBusKey id) { SOCKET TRemoteClientConnection::CreateSocket(const TNetAddr& addr) { SOCKET handle = socket(addr.Addr()->sa_family, SOCK_STREAM, 0); - Y_VERIFY(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(handle != INVALID_SOCKET, "failed to create socket: %s", LastSystemErrorText()); TSocketHolder s(handle); @@ -61,7 +61,7 @@ void TRemoteClientConnection::TryConnect() { if (AtomicGet(WriterData.Down)) { return; } - Y_VERIFY(!WriterData.Status.Connected); + Y_ABORT_UNLESS(!WriterData.Status.Connected); TInstant now = TInstant::Now(); @@ -306,7 +306,7 @@ EMessageStatus TRemoteClientConnection::SendMessageImpl(TBusMessage* msg, bool w } if (wait) { - Y_VERIFY(!Session->Queue->GetExecutor()->IsInExecutorThread()); + Y_ABORT_UNLESS(!Session->Queue->GetExecutor()->IsInExecutorThread()); GetSession()->ClientRemoteInFlight.Wait(); } else { if (!GetSession()->ClientRemoteInFlight.TryWait()) { diff --git a/library/cpp/messagebus/remote_client_session_semaphore.cpp b/library/cpp/messagebus/remote_client_session_semaphore.cpp index f877ed42570..ad37fae87c0 100644 --- a/library/cpp/messagebus/remote_client_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_client_session_semaphore.cpp @@ -12,12 +12,12 @@ TRemoteClientSessionSemaphore::TRemoteClientSessionSemaphore(TAtomicBase limit, , Current(0) , StopSignal(0) { - Y_VERIFY(limit > 0, "limit must be > 0"); + Y_ABORT_UNLESS(limit > 0, "limit must be > 0"); Y_UNUSED(Name); } TRemoteClientSessionSemaphore::~TRemoteClientSessionSemaphore() { - Y_VERIFY(AtomicGet(Current) == 0); + Y_ABORT_UNLESS(AtomicGet(Current) == 0); } bool TRemoteClientSessionSemaphore::TryAcquire() { diff --git a/library/cpp/messagebus/remote_connection.cpp b/library/cpp/messagebus/remote_connection.cpp index 740a7f6f8e0..24c2153730a 100644 --- a/library/cpp/messagebus/remote_connection.cpp +++ b/library/cpp/messagebus/remote_connection.cpp @@ -54,7 +54,7 @@ namespace NBus { } TRemoteConnection::~TRemoteConnection() { - Y_VERIFY(ReplyQueue.IsEmpty()); + Y_ABORT_UNLESS(ReplyQueue.IsEmpty()); } TRemoteConnection::TWriterData::TWriterData() @@ -67,8 +67,8 @@ namespace NBus { } TRemoteConnection::TWriterData::~TWriterData() { - Y_VERIFY(AtomicGet(Down)); - Y_VERIFY(SendQueue.Empty()); + Y_ABORT_UNLESS(AtomicGet(Down)); + Y_ABORT_UNLESS(SendQueue.Empty()); } bool TRemoteConnection::TReaderData::HasBytesInBuf(size_t bytes) noexcept { @@ -78,15 +78,15 @@ namespace NBus { } void TRemoteConnection::TWriterData::SetChannel(NEventLoop::TChannelPtr channel) { - Y_VERIFY(!Channel, "must not have channel"); - Y_VERIFY(Buffer.GetBuffer().Empty() && Buffer.LeftSize() == 0, "buffer must be empty"); - Y_VERIFY(State == WRITER_FILLING, "state must be initial"); + Y_ABORT_UNLESS(!Channel, "must not have channel"); + Y_ABORT_UNLESS(Buffer.GetBuffer().Empty() && Buffer.LeftSize() == 0, "buffer must be empty"); + Y_ABORT_UNLESS(State == WRITER_FILLING, "state must be initial"); Channel = channel; } void TRemoteConnection::TReaderData::SetChannel(NEventLoop::TChannelPtr channel) { - Y_VERIFY(!Channel, "must not have channel"); - Y_VERIFY(Buffer.Empty(), "buffer must be empty"); + Y_ABORT_UNLESS(!Channel, "must not have channel"); + Y_ABORT_UNLESS(Buffer.Empty(), "buffer must be empty"); Channel = channel; } @@ -119,7 +119,7 @@ namespace NBus { } TRemoteConnection::TReaderData::~TReaderData() { - Y_VERIFY(AtomicGet(Down)); + Y_ABORT_UNLESS(AtomicGet(Down)); } void TRemoteConnection::Send(TNonDestroyingAutoPtr<TBusMessage> msg) { @@ -197,13 +197,13 @@ namespace NBus { } void TRemoteConnection::ProcessItem(TWriterTag, TReconnectTag, ui32 socketVersion) { - Y_VERIFY(socketVersion <= WriterData.SocketVersion, "something weird"); + Y_ABORT_UNLESS(socketVersion <= WriterData.SocketVersion, "something weird"); if (WriterData.SocketVersion != socketVersion) { return; } - Y_VERIFY(WriterData.Status.Connected, "must be connected at this point"); - Y_VERIFY(!!WriterData.Channel, "must have channel at this point"); + Y_ABORT_UNLESS(WriterData.Status.Connected, "must be connected at this point"); + Y_ABORT_UNLESS(!!WriterData.Channel, "must have channel at this point"); WriterData.Status.Connected = false; WriterData.DropChannel(); @@ -670,7 +670,7 @@ namespace NBus { void TRemoteConnection::CallSerialize(TBusMessage* msg, TBuffer& buffer) const { size_t posForAssertion = buffer.Size(); Proto->Serialize(msg, buffer); - Y_VERIFY(buffer.Size() >= posForAssertion, + Y_ABORT_UNLESS(buffer.Size() >= posForAssertion, "incorrect Serialize implementation, pos before serialize: %d, pos after serialize: %d", int(posForAssertion), int(buffer.Size())); } @@ -808,7 +808,7 @@ namespace NBus { TBusMessage* r = DeserializeMessage(readDataRef, &header, &ReaderData.Status.Incremental.MessageCounter, &deserializeFailureStatus); if (!r) { - Y_VERIFY(deserializeFailureStatus != MESSAGE_OK, "state check"); + Y_ABORT_UNLESS(deserializeFailureStatus != MESSAGE_OK, "state check"); LWPROBE(Error, ToString(deserializeFailureStatus), ToString(PeerAddr), ""); ReaderData.Status.Incremental.StatusCounter[deserializeFailureStatus] += 1; ScheduleShutdownOnServerOrReconnectOnClient(deserializeFailureStatus, false); @@ -960,7 +960,7 @@ namespace NBus { } void TRemoteConnection::FireClientConnectionEvent(TClientConnectionEvent::EType type) { - Y_VERIFY(Session->IsSource_, "state check"); + Y_ABORT_UNLESS(Session->IsSource_, "state check"); TClientConnectionEvent event(type, ConnectionId, PeerAddr); TRemoteClientSession* session = CheckedCast<TRemoteClientSession*>(Session.Get()); session->ClientHandler->OnClientConnectionEvent(event); diff --git a/library/cpp/messagebus/remote_server_connection.cpp b/library/cpp/messagebus/remote_server_connection.cpp index 74be34ded98..cc2336d20de 100644 --- a/library/cpp/messagebus/remote_server_connection.cpp +++ b/library/cpp/messagebus/remote_server_connection.cpp @@ -19,7 +19,7 @@ void TRemoteServerConnection::Init(SOCKET socket, TInstant now) { WriterData.Status.ConnectTime = now; WriterData.Status.Connected = true; - Y_VERIFY(socket != INVALID_SOCKET, "must be a valid socket"); + Y_ABORT_UNLESS(socket != INVALID_SOCKET, "must be a valid socket"); TSocket readSocket(socket); TSocket writeSocket = readSocket; diff --git a/library/cpp/messagebus/remote_server_session.cpp b/library/cpp/messagebus/remote_server_session.cpp index 6abbf88a606..98ca6436f6c 100644 --- a/library/cpp/messagebus/remote_server_session.cpp +++ b/library/cpp/messagebus/remote_server_session.cpp @@ -201,6 +201,6 @@ void TRemoteServerSession::PauseInput(bool pause) { } unsigned TRemoteServerSession::GetActualListenPort() { - Y_VERIFY(Config.ListenPort > 0, "state check"); + Y_ABORT_UNLESS(Config.ListenPort > 0, "state check"); return Config.ListenPort; } diff --git a/library/cpp/messagebus/remote_server_session_semaphore.cpp b/library/cpp/messagebus/remote_server_session_semaphore.cpp index 6094a3586e6..ffea5fb85cc 100644 --- a/library/cpp/messagebus/remote_server_session_semaphore.cpp +++ b/library/cpp/messagebus/remote_server_session_semaphore.cpp @@ -16,14 +16,14 @@ TRemoteServerSessionSemaphore::TRemoteServerSessionSemaphore( , PausedByUser(0) , StopSignal(0) { - Y_VERIFY(limitCount > 0, "limit must be > 0"); + Y_ABORT_UNLESS(limitCount > 0, "limit must be > 0"); Y_UNUSED(Name); } TRemoteServerSessionSemaphore::~TRemoteServerSessionSemaphore() { - Y_VERIFY(AtomicGet(CurrentCount) == 0); + Y_ABORT_UNLESS(AtomicGet(CurrentCount) == 0); // TODO: fix spider and enable - //Y_VERIFY(AtomicGet(CurrentSize) == 0); + //Y_ABORT_UNLESS(AtomicGet(CurrentSize) == 0); } bool TRemoteServerSessionSemaphore::TryWait() { diff --git a/library/cpp/messagebus/scheduler/scheduler.cpp b/library/cpp/messagebus/scheduler/scheduler.cpp index 5a5fe528943..149d12c41be 100644 --- a/library/cpp/messagebus/scheduler/scheduler.cpp +++ b/library/cpp/messagebus/scheduler/scheduler.cpp @@ -23,7 +23,7 @@ TScheduler::TScheduler() } TScheduler::~TScheduler() { - Y_VERIFY(StopThread, "state check"); + Y_ABORT_UNLESS(StopThread, "state check"); } size_t TScheduler::Size() const { @@ -34,7 +34,7 @@ size_t TScheduler::Size() const { void TScheduler::Stop() { { TGuard<TLock> guard(Lock); - Y_VERIFY(!StopThread, "Scheduler already stopped"); + Y_ABORT_UNLESS(!StopThread, "Scheduler already stopped"); StopThread = true; CondVar.Signal(); } @@ -98,7 +98,7 @@ void TScheduler::SchedulerThread() { } // signal comes if either scheduler is to be stopped of there's work to do - Y_VERIFY(!!NextItem, "state check"); + Y_ABORT_UNLESS(!!NextItem, "state check"); if (TInstant::Now() < NextItem->GetScheduleTime()) { // NextItem is updated since WaitD diff --git a/library/cpp/messagebus/session_impl.cpp b/library/cpp/messagebus/session_impl.cpp index ddf9f360c43..a3b480584c8 100644 --- a/library/cpp/messagebus/session_impl.cpp +++ b/library/cpp/messagebus/session_impl.cpp @@ -76,10 +76,10 @@ namespace { copy.ConnectTimeout = copy.SendTimeout; } - Y_VERIFY(copy.SendTimeout > 0, "SendTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); - Y_VERIFY(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); - Y_VERIFY(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); + Y_ABORT_UNLESS(copy.SendTimeout > 0, "SendTimeout must be > 0"); + Y_ABORT_UNLESS(copy.TotalTimeout > 0, "TotalTimeout must be > 0"); + Y_ABORT_UNLESS(copy.ConnectTimeout > 0, "ConnectTimeout must be > 0"); + Y_ABORT_UNLESS(copy.TotalTimeout >= copy.SendTimeout, "TotalTimeout must be >= SendTimeout"); if (!copy.Name) { copy.Name = name; @@ -117,10 +117,10 @@ TBusSessionImpl::TBusSessionImpl(bool isSource, TBusMessageQueue* queue, TBusPro } TBusSessionImpl::~TBusSessionImpl() { - Y_VERIFY(Down); - Y_VERIFY(ShutdownCompleteEvent.WaitT(TDuration::Zero())); - Y_VERIFY(!WriteEventLoop.IsRunning()); - Y_VERIFY(!ReadEventLoop.IsRunning()); + Y_ABORT_UNLESS(Down); + Y_ABORT_UNLESS(ShutdownCompleteEvent.WaitT(TDuration::Zero())); + Y_ABORT_UNLESS(!WriteEventLoop.IsRunning()); + Y_ABORT_UNLESS(!ReadEventLoop.IsRunning()); } TBusSessionStatus::TBusSessionStatus() @@ -136,7 +136,7 @@ void TBusSessionImpl::Shutdown() { return; } - Y_VERIFY(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); + Y_ABORT_UNLESS(Queue->IsRunning(), "Session must be shut down prior to queue shutdown"); TUseAfterFreeCheckerGuard handlerAliveCheckedGuard(ErrorHandler->UseAfterFreeChecker); @@ -205,7 +205,7 @@ size_t TBusSessionImpl::GetInFlightImpl(const TNetAddr& addr) const { } void TBusSessionImpl::GetInFlightBulk(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_ABORT_UNLESS(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetInFlightImpl(addrs[i]); } @@ -221,7 +221,7 @@ size_t TBusSessionImpl::GetConnectSyscallsNumForTestImpl(const TNetAddr& addr) c } void TBusSessionImpl::GetConnectSyscallsNumBulkForTest(TArrayRef<const TNetAddr> addrs, TArrayRef<size_t> results) const { - Y_VERIFY(addrs.size() == results.size(), "input.size != output.size"); + Y_ABORT_UNLESS(addrs.size() == results.size(), "input.size != output.size"); for (size_t i = 0; i < addrs.size(); ++i) { results[i] = GetConnectSyscallsNumForTestImpl(addrs[i]); } @@ -232,7 +232,7 @@ void TBusSessionImpl::FillStatus() { TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { // Probably useless, because it returns cached info now - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_ABORT_UNLESS(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -248,7 +248,7 @@ TString TBusSessionImpl::GetStatus(ui16 flags) { } TConnectionStatusMonRecord TBusSessionImpl::GetStatusProtobuf() { - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_ABORT_UNLESS(!Queue->GetExecutor()->IsInExecutorThread(), "GetStatus must not be called from executor thread"); TGuard<TMutex> guard(StatusData.StatusDumpCachedMutex); @@ -471,8 +471,8 @@ void TBusSessionImpl::Act(TConnectionTag) { EShutdownState shutdownState = ConnectionsData.ShutdownState.State.Get(); if (shutdownState == SS_SHUTDOWN_COMPLETE) { - Y_VERIFY(GetRemoveConnectionQueue()->IsEmpty()); - Y_VERIFY(GetOnAcceptQueue()->IsEmpty()); + Y_ABORT_UNLESS(GetRemoveConnectionQueue()->IsEmpty()); + Y_ABORT_UNLESS(GetOnAcceptQueue()->IsEmpty()); } GetRemoveConnectionQueue()->DequeueAllLikelyEmpty(); @@ -495,7 +495,7 @@ void TBusSessionImpl::Listen(const TVector<TBindResult>& bindTo, TBusMessageQueu if (actualPort == -1) { actualPort = br.Addr.GetPort(); } else { - Y_VERIFY(actualPort == br.Addr.GetPort(), "state check"); + Y_ABORT_UNLESS(actualPort == br.Addr.GetPort(), "state check"); } if (Config.SocketToS >= 0) { SetSocketToS(*br.Socket, &(br.Addr), Config.SocketToS); @@ -531,7 +531,7 @@ void TBusSessionImpl::InsertConnectionLockAcquired(TRemoteConnection* connection // after reconnect, if previous connections wasn't shutdown yet bool inserted2 = ConnectionsById.insert(std::make_pair(connection->ConnectionId, connection)).second; - Y_VERIFY(inserted2, "state check: must be inserted (2)"); + Y_ABORT_UNLESS(inserted2, "state check: must be inserted (2)"); SendSnapshotToStatusActor(); } @@ -614,7 +614,7 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnection(const TBusSocketAddr& addr, return TRemoteConnectionPtr(); } - Y_VERIFY(IsSource_, "must be source"); + Y_ABORT_UNLESS(IsSource_, "must be source"); TRemoteConnectionPtr c(new TRemoteClientConnection(VerifyDynamicCast<TRemoteClientSession*>(this), ++LastConnectionId, addr.ToNetAddr())); InsertConnectionLockAcquired(c.Get()); diff --git a/library/cpp/messagebus/session_job_count.cpp b/library/cpp/messagebus/session_job_count.cpp index 33322b19102..bdbf35c2b92 100644 --- a/library/cpp/messagebus/session_job_count.cpp +++ b/library/cpp/messagebus/session_job_count.cpp @@ -11,7 +11,7 @@ TBusSessionJobCount::TBusSessionJobCount() } TBusSessionJobCount::~TBusSessionJobCount() { - Y_VERIFY(JobCount == 0, "must be 0 job count to destroy job"); + Y_ABORT_UNLESS(JobCount == 0, "must be 0 job count to destroy job"); } void TBusSessionJobCount::WaitForZero() { diff --git a/library/cpp/messagebus/shutdown_state.cpp b/library/cpp/messagebus/shutdown_state.cpp index a4e2bfa8b26..afe07890c69 100644 --- a/library/cpp/messagebus/shutdown_state.cpp +++ b/library/cpp/messagebus/shutdown_state.cpp @@ -3,11 +3,11 @@ #include <util/system/yassert.h> void TAtomicShutdownState::ShutdownCommand() { - Y_VERIFY(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); + Y_ABORT_UNLESS(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND)); } void TAtomicShutdownState::CompleteShutdown() { - Y_VERIFY(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); + Y_ABORT_UNLESS(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE)); ShutdownComplete.Signal(); } @@ -16,5 +16,5 @@ bool TAtomicShutdownState::IsRunning() { } TAtomicShutdownState::~TAtomicShutdownState() { - Y_VERIFY(SS_SHUTDOWN_COMPLETE == State.Get()); + Y_ABORT_UNLESS(SS_SHUTDOWN_COMPLETE == State.Get()); } diff --git a/library/cpp/messagebus/storage.cpp b/library/cpp/messagebus/storage.cpp index efefc87340c..402ec63c939 100644 --- a/library/cpp/messagebus/storage.cpp +++ b/library/cpp/messagebus/storage.cpp @@ -8,7 +8,7 @@ namespace NBus { } TTimedMessages::~TTimedMessages() { - Y_VERIFY(Items.empty()); + Y_ABORT_UNLESS(Items.empty()); } void TTimedMessages::PushBack(TNonDestroyingAutoPtr<TBusMessage> m) { @@ -64,8 +64,8 @@ namespace NBus { } TSyncAckMessages::~TSyncAckMessages() { - Y_VERIFY(KeyToMessage.empty()); - Y_VERIFY(TimedItems.empty()); + Y_ABORT_UNLESS(KeyToMessage.empty()); + Y_ABORT_UNLESS(TimedItems.empty()); } void TSyncAckMessages::Push(TBusMessagePtrAndHeader& m) { @@ -77,7 +77,7 @@ namespace NBus { TValue value = {m.MessagePtr.Release()}; std::pair<TKeyToMessage::iterator, bool> p = KeyToMessage.insert(TKeyToMessage::value_type(m.Header.Id, value)); - Y_VERIFY(p.second, "non-unique id; %s", value.Message->Describe().data()); + Y_ABORT_UNLESS(p.second, "non-unique id; %s", value.Message->Describe().data()); TTimedItem item = {m.Header.Id, m.Header.SendTime}; TimedItems.push_back(item); @@ -147,7 +147,7 @@ namespace NBus { void TSyncAckMessages::RemoveAll(const TMessagesPtrs& messages) { for (auto message : messages) { TKeyToMessage::iterator it = KeyToMessage.find(message->GetHeader()->Id); - Y_VERIFY(it != KeyToMessage.end(), "delete non-existent message"); + Y_ABORT_UNLESS(it != KeyToMessage.end(), "delete non-existent message"); KeyToMessage.erase(it); } } diff --git a/library/cpp/messagebus/synchandler.cpp b/library/cpp/messagebus/synchandler.cpp index 8e891d66b30..daf71534896 100644 --- a/library/cpp/messagebus/synchandler.cpp +++ b/library/cpp/messagebus/synchandler.cpp @@ -76,7 +76,7 @@ public: private: void SignalResult(TBusSyncMessageData* data, TBusMessage* pReply, EMessageStatus status) const { - Y_VERIFY(data, "Message data is set to NULL."); + Y_ABORT_UNLESS(data, "Message data is set to NULL."); TGuard<TMutex> G(data->ReplyLock); data->Reply = pReply; data->ReplyStatus = status; @@ -115,7 +115,7 @@ namespace NBus { } TBusMessage* SendSyncMessage(TBusMessage* pMessage, EMessageStatus& status, const TNetAddr* addr = nullptr) { - Y_VERIFY(!Queue->GetExecutor()->IsInExecutorThread(), + Y_ABORT_UNLESS(!Queue->GetExecutor()->IsInExecutorThread(), "SendSyncMessage must not be called from executor thread"); TBusMessage* reply = nullptr; @@ -134,7 +134,7 @@ namespace NBus { if (status == MESSAGE_OK) { data->ReplyEvent.Wait(data->ReplyLock); TBusSyncMessageData* rdata = static_cast<TBusSyncMessageData*>(pMessage->Data); - Y_VERIFY(rdata == data.Get(), "Message data pointer should not be modified."); + Y_ABORT_UNLESS(rdata == data.Get(), "Message data pointer should not be modified."); reply = rdata->Reply; status = rdata->ReplyStatus; } diff --git a/library/cpp/messagebus/test/example/client/client.cpp b/library/cpp/messagebus/test/example/client/client.cpp index 89b5f2c9beb..8d0f0584e08 100644 --- a/library/cpp/messagebus/test/example/client/client.cpp +++ b/library/cpp/messagebus/test/example/client/client.cpp @@ -23,7 +23,7 @@ namespace NCalculator { } void OnReply(TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response0) override { - Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); + Y_ABORT_UNLESS(response0->GetHeader()->Type == TResponse::MessageType, "wrong response"); TResponse* response = VerifyDynamicCast<TResponse*>(response0.Get()); if (request->GetHeader()->Type == TRequestSum::MessageType) { TRequestSum* requestSum = VerifyDynamicCast<TRequestSum*>(request.Get()); diff --git a/library/cpp/messagebus/test/helper/alloc_counter.h b/library/cpp/messagebus/test/helper/alloc_counter.h index 7c4010714f5..93972b52ddd 100644 --- a/library/cpp/messagebus/test/helper/alloc_counter.h +++ b/library/cpp/messagebus/test/helper/alloc_counter.h @@ -16,6 +16,6 @@ public: } ~TAllocCounter() { - Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many"); + Y_ABORT_UNLESS(AtomicDecrement(*CountPtr) >= 0, "released too many"); } }; diff --git a/library/cpp/messagebus/test/helper/example.cpp b/library/cpp/messagebus/test/helper/example.cpp index 7c6d704042c..1ef28091116 100644 --- a/library/cpp/messagebus/test/helper/example.cpp +++ b/library/cpp/messagebus/test/helper/example.cpp @@ -68,11 +68,11 @@ TExampleProtocol::~TExampleProtocol() { // so it could be reported in test return; } - Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); - Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); - Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); - Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); - Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); + Y_ABORT_UNLESS(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount)); + Y_ABORT_UNLESS(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount)); + Y_ABORT_UNLESS(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized)); + Y_ABORT_UNLESS(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized)); + Y_ABORT_UNLESS(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount)); } void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) { @@ -277,5 +277,5 @@ void TExampleServer::OnMessage(TOnMessageContext& mess) { status = mess.SendReplyMove(reply); } - Y_VERIFY(status == MESSAGE_OK, "failed to send reply: %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to send reply: %s", ToString(status).data()); } diff --git a/library/cpp/messagebus/test/helper/wait_for.h b/library/cpp/messagebus/test/helper/wait_for.h index f09958d4c04..b8363900b80 100644 --- a/library/cpp/messagebus/test/helper/wait_for.h +++ b/library/cpp/messagebus/test/helper/wait_for.h @@ -10,5 +10,5 @@ Sleep(TDuration::MilliSeconds(1)); \ } \ /* TODO: use UNIT_ASSERT if in unittest thread */ \ - Y_VERIFY(condition, "condition failed after 10 seconds wait"); \ + Y_ABORT_UNLESS(condition, "condition failed after 10 seconds wait"); \ } while (0) diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index 84893192789..3084c9e01c5 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -150,7 +150,7 @@ TAutoPtr<TBusMessage> NewRequest() { void CheckRequest(TPerftestRequest* request) { const TString& data = request->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '?', "must be question mark"); + Y_ABORT_UNLESS(data.at(i) == '?', "must be question mark"); } } @@ -164,7 +164,7 @@ TAutoPtr<TPerftestResponse> NewResponse(TPerftestRequest* request) { void CheckResponse(TPerftestResponse* response) { const TString& data = response->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { - Y_VERIFY(data.at(i) == '.', "must be dot"); + Y_ABORT_UNLESS(data.at(i) == '.', "must be dot"); } } @@ -416,8 +416,8 @@ public: : TPerftestServerCommon("server") , TBusModule("fast") { - Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); - Y_VERIFY(StartInput(), "failed to start input"); + Y_ABORT_UNLESS(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module"); + Y_ABORT_UNLESS(StartInput(), "failed to start input"); } ~TPerftestUsingModule() override { @@ -479,7 +479,7 @@ TVector<TNetAddr> ParseNodes(const TString nodes) { for (int i = 0; i < int(numh); i++) { const TNetworkAddress& networkAddress = ParseNetworkAddress(hosts[i].data()); - Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses"); + Y_ABORT_UNLESS(networkAddress.Begin() != networkAddress.End(), "no addresses"); r.push_back(TNetAddr(networkAddress, &*networkAddress.Begin())); } diff --git a/library/cpp/messagebus/test/perftest/simple_proto.cpp b/library/cpp/messagebus/test/perftest/simple_proto.cpp index 19d6c15b9d9..3e28413325c 100644 --- a/library/cpp/messagebus/test/perftest/simple_proto.cpp +++ b/library/cpp/messagebus/test/perftest/simple_proto.cpp @@ -7,7 +7,7 @@ using namespace NBus; void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) { - Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess)); + Y_ABORT_UNLESS(typeid(TSimpleMessage) == typeid(*mess)); const TSimpleMessage* typed = static_cast<const TSimpleMessage*>(mess); data.Append((const char*)&typed->Payload, 4); } diff --git a/library/cpp/messagebus/test/ut/messagebus_ut.cpp b/library/cpp/messagebus/test/ut/messagebus_ut.cpp index 8d2f4aa444f..8f6aa6a2956 100644 --- a/library/cpp/messagebus/test/ut/messagebus_ut.cpp +++ b/library/cpp/messagebus/test/ut/messagebus_ut.cpp @@ -31,7 +31,7 @@ namespace { } void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override { - Y_VERIFY(AtomicGet(SentCompleted), "must be completed"); + Y_ABORT_UNLESS(AtomicGet(SentCompleted), "must be completed"); TExampleClient::OnReply(mess, reply); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override { Y_UNUSED(message); - Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); TestSync.CheckAndIncrement((failures++) * 2); } @@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { status = client.Session->SendMessageAutoPtr(message, &noServerAddr); } - Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); if (count == 0) { // lame way to wait until it is connected @@ -266,7 +266,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { TSystemEvent ErrorHappened; void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override { - Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got status: %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got status: %s", ToString(status).data()); ErrorHappened.Signal(); } }; @@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { } void OnMessage(TOnMessageContext& mess) override { - Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here"); + Y_ABORT_UNLESS(mess.IsConnectionAlive(), "connection should be alive here"); TAutoPtr<TOnMessageContext> delayedMsg(new TOnMessageContext); delayedMsg->Swap(mess); auto g(Guard(Lock_)); @@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data()); } }; @@ -432,7 +432,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); + Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "only shutdown allowed"); } }; @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override { TestSync.WaitForAndIncrement(1); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); + Y_ABORT_UNLESS(status == MESSAGE_MESSAGE_TOO_LARGE, "status"); } }; @@ -697,7 +697,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { TestSync.WaitForAndIncrement(0); - Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "must be connection failed, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "must be connection failed, got %s", ToString(status).data()); mess.Destroy(); TestSync.CheckAndIncrement(1); } @@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override { TestSync.CheckAndIncrement(0); - Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data()); // check reset is possible here message->Reset(); @@ -755,7 +755,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { client.Session->Shutdown(); ok = client.Session->SendMessageOneWay(message); - Y_VERIFY(ok == MESSAGE_SHUTDOWN, "must be shutdown when sending during shutdown, got %s", ToString(ok).data()); + Y_ABORT_UNLESS(ok == MESSAGE_SHUTDOWN, "must be shutdown when sending during shutdown, got %s", ToString(ok).data()); // check reset is possible here message->Reset(); @@ -1074,7 +1074,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount), &noServerAddr); - Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); client.TestSync.WaitForAndIncrement(count * 2 + 1); // First connection attempt is for connect call; second one is to get connect result. @@ -1085,7 +1085,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount), &noServerAddr); - Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); client.TestSync.WaitForAndIncrement(count * 2 + 1); // First connection attempt is for connect call; second one is to get connect result. @@ -1107,7 +1107,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount), &noServerAddr); - Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); client.TestSync.WaitForAndIncrement(count * 2 + 1); // First connection attempt is for connect call; second one is to get connect result. @@ -1134,7 +1134,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount), &noServerAddr); - Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); + Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data()); client.TestSync.WaitForAndIncrement(count * 2 + 1); // First connection attempt is for connect call; second one is to get connect result. diff --git a/library/cpp/messagebus/test/ut/module_client_ut.cpp b/library/cpp/messagebus/test/ut/module_client_ut.cpp index ebfe185cc6d..a172b06bd2c 100644 --- a/library/cpp/messagebus/test/ut/module_client_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_client_ut.cpp @@ -120,13 +120,13 @@ Y_UNIT_TEST_SUITE(BusJobTest) { void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { Y_UNUSED(mess); Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); + Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status)); } TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) { Y_UNUSED(mess); RepliesLatch.CountDown(); - Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); + Y_ABORT_UNLESS(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers"); job->Cancel(MESSAGE_UNKNOWN); return nullptr; } @@ -178,9 +178,9 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* req, TBusMessage* resp) { - Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data()); - Y_VERIFY(req == SentMessage, "checking request"); - Y_VERIFY(resp == nullptr, "checking response"); + Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data()); + Y_ABORT_UNLESS(req == SentMessage, "checking request"); + Y_ABORT_UNLESS(resp == nullptr, "checking response"); GotReplyLatch.CountDown(); } @@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { void ReplyHandler(TBusJob* job, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) { Y_UNUSED(mess); Y_UNUSED(reply); - Y_VERIFY(status == MESSAGE_OK, "failed to get reply"); + Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to get reply"); if (AtomicIncrement(ReplyCount) == 1) { TestSync->WaitForAndIncrement(1); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); @@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) { } void HandleReply(TBusJob*, EMessageStatus status, TBusMessage*, TBusMessage*) { - Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); + Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status)); TestSync.CheckAndIncrement(1); } diff --git a/library/cpp/messagebus/test/ut/module_server_ut.cpp b/library/cpp/messagebus/test/ut/module_server_ut.cpp index 88fe1dd9b6d..b0e6ac38da4 100644 --- a/library/cpp/messagebus/test/ut/module_server_ut.cpp +++ b/library/cpp/messagebus/test/ut/module_server_ut.cpp @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { TJobHandler Start(TBusJob* job, TBusMessage* mess) override { WaitTwoRequestsLatch.CountDown(); - Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); + Y_ABORT_UNLESS(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops"); VerifyDynamicCast<TExampleRequest*>(mess); @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) { MessageReceivedEvent.Signal(); - Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); + Y_ABORT_UNLESS(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops"); job->SendReply(new TExampleResponse(&Proto.ResponseCount)); return nullptr; diff --git a/library/cpp/messagebus/test/ut/one_way_ut.cpp b/library/cpp/messagebus/test/ut/one_way_ut.cpp index 9c21227e2bd..0b90985289f 100644 --- a/library/cpp/messagebus/test/ut/one_way_ut.cpp +++ b/library/cpp/messagebus/test/ut/one_way_ut.cpp @@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) { void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override { Y_UNUSED(mess); - Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); + Y_ABORT_UNLESS(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status)); GotTooLarge.Signal(); } diff --git a/library/cpp/messagebus/use_after_free_checker.cpp b/library/cpp/messagebus/use_after_free_checker.cpp index 4904e7c614a..0b35fcbdfe7 100644 --- a/library/cpp/messagebus/use_after_free_checker.cpp +++ b/library/cpp/messagebus/use_after_free_checker.cpp @@ -13,10 +13,10 @@ TUseAfterFreeChecker::TUseAfterFreeChecker() } TUseAfterFreeChecker::~TUseAfterFreeChecker() { - Y_VERIFY(Magic == VALID, "Corrupted"); + Y_ABORT_UNLESS(Magic == VALID, "Corrupted"); Magic = INVALID; } void TUseAfterFreeChecker::CheckNotFreed() const { - Y_VERIFY(Magic == VALID, "Freed or corrupted"); + Y_ABORT_UNLESS(Magic == VALID, "Freed or corrupted"); } diff --git a/library/cpp/messagebus/use_count_checker.cpp b/library/cpp/messagebus/use_count_checker.cpp index 32eee10431b..ae18d9f9946 100644 --- a/library/cpp/messagebus/use_count_checker.cpp +++ b/library/cpp/messagebus/use_count_checker.cpp @@ -8,7 +8,7 @@ TUseCountChecker::TUseCountChecker() { TUseCountChecker::~TUseCountChecker() { auto count = Counter.Val(); - Y_VERIFY(count == 0, "must not release when count is not zero: %ld", (long)count); + Y_ABORT_UNLESS(count == 0, "must not release when count is not zero: %ld", (long)count); } void TUseCountChecker::Inc() { diff --git a/library/cpp/messagebus/vector_swaps.h b/library/cpp/messagebus/vector_swaps.h index b920bcf03ea..f0d23c6078e 100644 --- a/library/cpp/messagebus/vector_swaps.h +++ b/library/cpp/messagebus/vector_swaps.h @@ -122,7 +122,7 @@ public: size_t newCapacity = FastClp2(n); TVectorSwaps<T> tmp; tmp.Start = (T*)malloc(sizeof(T) * newCapacity); - Y_VERIFY(!!tmp.Start); + Y_ABORT_UNLESS(!!tmp.Start); tmp.EndOfStorage = tmp.Start + newCapacity; @@ -146,7 +146,7 @@ public: template <class TIterator> void insert(iterator pos, TIterator b, TIterator e) { - Y_VERIFY(pos == end(), "TODO: only insert at the end is implemented"); + Y_ABORT_UNLESS(pos == end(), "TODO: only insert at the end is implemented"); size_t count = e - b; diff --git a/library/cpp/messagebus/www/html_output.h b/library/cpp/messagebus/www/html_output.h index 27e77adefa7..cf9cba831d6 100644 --- a/library/cpp/messagebus/www/html_output.h +++ b/library/cpp/messagebus/www/html_output.h @@ -10,7 +10,7 @@ extern Y_POD_THREAD(IOutputStream*) HtmlOutputStreamPtr; static IOutputStream& HtmlOutputStream() { - Y_VERIFY(!!HtmlOutputStreamPtr); + Y_ABORT_UNLESS(!!HtmlOutputStreamPtr); return *HtmlOutputStreamPtr; } diff --git a/library/cpp/messagebus/www/www.cpp b/library/cpp/messagebus/www/www.cpp index 6c8b4bc732f..a52ad404ff7 100644 --- a/library/cpp/messagebus/www/www.cpp +++ b/library/cpp/messagebus/www/www.cpp @@ -38,7 +38,7 @@ namespace { TVector<std::pair<TString, TValuePtr>> Entries; TValuePtr FindByName(TStringBuf name) { - Y_VERIFY(!!name); + Y_ABORT_UNLESS(!!name); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].first == name) { @@ -49,7 +49,7 @@ namespace { } TString FindNameByPtr(TValuePtr value) { - Y_VERIFY(!!value); + Y_ABORT_UNLESS(!!value); for (unsigned i = 0; i < Entries.size(); ++i) { if (Entries[i].second.Get() == value.Get()) { @@ -61,7 +61,7 @@ namespace { } void Add(TValuePtr p) { - Y_VERIFY(!!p); + Y_ABORT_UNLESS(!!p); // Do not add twice for (unsigned i = 0; i < Entries.size(); ++i) { @@ -175,27 +175,27 @@ struct TBusWww::TImpl { TMutex Mutex; void RegisterClientSession(TBusClientSessionPtr s) { - Y_VERIFY(!!s); + Y_ABORT_UNLESS(!!s); TGuard<TMutex> g(Mutex); ClientSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterServerSession(TBusServerSessionPtr s) { - Y_VERIFY(!!s); + Y_ABORT_UNLESS(!!s); TGuard<TMutex> g(Mutex); ServerSessions.Add(s.Get()); Queues.Add(s->GetQueue()); } void RegisterQueue(TBusMessageQueuePtr q) { - Y_VERIFY(!!q); + Y_ABORT_UNLESS(!!q); TGuard<TMutex> g(Mutex); Queues.Add(q); } void RegisterModule(TBusModule* module) { - Y_VERIFY(!!module); + Y_ABORT_UNLESS(!!module); TGuard<TMutex> g(Mutex); { @@ -227,7 +227,7 @@ struct TBusWww::TImpl { serverSession = ServerSessions.FindByName(sessionName); session = serverSession.Get(); } - Y_VERIFY(!!session); + Y_ABORT_UNLESS(!!session); return Queues.FindNameByPtr(session->GetQueue()); } @@ -831,7 +831,7 @@ struct TBusWwwHttpServer::TImpl: public THttpServer::ICallBack { THttpServer HttpServer; static THttpServer::TOptions MakeHttpServerOptions(unsigned port) { - Y_VERIFY(port > 0); + Y_ABORT_UNLESS(port > 0); THttpServer::TOptions r; r.Port = port; return r; |