diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-06-30 14:22:26 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-06-30 14:22:26 +0300 |
commit | 93a8bbb01d574d1c55ea51172eca469785df35e3 (patch) | |
tree | 3b3ed5e54e4c7b931b2e2c48409d14cb54d918e3 /library/cpp | |
parent | aaf08878eedef2e56302f84ec81213ce801f5b16 (diff) | |
download | ydb-93a8bbb01d574d1c55ea51172eca469785df35e3.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/neh/factory.h | 4 | ||||
-rw-r--r-- | library/cpp/neh/http2.cpp | 51 | ||||
-rw-r--r-- | library/cpp/neh/http_common.h | 6 | ||||
-rw-r--r-- | library/cpp/neh/neh.cpp | 8 | ||||
-rw-r--r-- | library/cpp/neh/neh.h | 2 |
5 files changed, 20 insertions, 51 deletions
diff --git a/library/cpp/neh/factory.h b/library/cpp/neh/factory.h index 17bebef8ed..c3ea3eed05 100644 --- a/library/cpp/neh/factory.h +++ b/library/cpp/neh/factory.h @@ -12,10 +12,6 @@ namespace NNeh { } virtual IRequesterRef CreateRequester(IOnRequest* cb, const TParsedLocation& loc) = 0; virtual THandleRef ScheduleRequest(const TMessage& msg, IOnRecv* fallback, TServiceStatRef&) = 0; - virtual THandleRef ScheduleAsyncRequest(const TMessage& msg, IOnRecv* fallback, TServiceStatRef& statRef, bool useAsyncSendRequest = false) { - Y_UNUSED(useAsyncSendRequest); - return ScheduleRequest(msg, fallback, statRef); - } virtual TStringBuf Scheme() const noexcept = 0; virtual bool SetOption(TStringBuf name, TStringBuf value) { Y_UNUSED(name); diff --git a/library/cpp/neh/http2.cpp b/library/cpp/neh/http2.cpp index d8db33e369..feaa45c5c9 100644 --- a/library/cpp/neh/http2.cpp +++ b/library/cpp/neh/http2.cpp @@ -516,7 +516,7 @@ namespace { #endif } - void StartRequest(THttpRequestRef req, const TEndpoint& ep, size_t addrId, TDuration slowConn, bool useAsyncSendRequest = false) { + void StartRequest(THttpRequestRef req, const TEndpoint& ep, size_t addrId, TDuration slowConn) { { //thread safe linking connection->request TGuard<TSpinLock> g(SL_); @@ -532,7 +532,7 @@ namespace { ConnectDeadline_ = THttp2Options::ConnectTimeout - slowConn; } DBGOUT("AsyncConnect to " << ep.IpToString()); - AS_.AsyncConnect(ep, std::bind(&THttpConn::OnConnect, THttpConnRef(this), _1, _2, useAsyncSendRequest), connectDeadline); + AS_.AsyncConnect(ep, std::bind(&THttpConn::OnConnect, THttpConnRef(this), _1, _2), connectDeadline); } catch (...) { ReleaseRequest(); throw; @@ -540,7 +540,7 @@ namespace { } //start next request on keep-alive connection - bool StartNextRequest(THttpRequestRef& req, bool useAsyncSendRequest = false) { + bool StartNextRequest(THttpRequestRef& req) { if (Finalized_) { return false; } @@ -555,16 +555,12 @@ namespace { BeginReadResponse_ = false; try { - if (!useAsyncSendRequest) { - TErrorCode ec; - SendRequest(req->BuildRequest(), ec); //throw std::bad_alloc - if (ec.Value() == ECANCELED) { - OnCancel(); - } else if (ec) { - OnError(ec); - } - } else { - SendRequestAsync(req->BuildRequest()); //throw std::bad_alloc + TErrorCode ec; + SendRequest(req->BuildRequest(), ec); //throw std::bad_alloc + if (ec.Value() == ECANCELED) { + OnCancel(); + } else if (ec) { + OnError(ec); } } catch (...) { OnError(CurrentExceptionMessage()); @@ -650,7 +646,7 @@ namespace { } //can be called only from asio - void OnConnect(const TErrorCode& ec, IHandlingContext& ctx, bool useAsyncSendRequest = false) { + void OnConnect(const TErrorCode& ec, IHandlingContext& ctx) { DBGOUT("THttpConn::OnConnect: " << ec.Value()); if (Y_UNLIKELY(ec)) { if (ec.Value() == ETIMEDOUT && ConnectDeadline_.GetValue()) { @@ -712,14 +708,10 @@ namespace { THttpRequestBuffersPtr ptr(req->BuildRequest()); PrepareParser(); - if (!useAsyncSendRequest) { - TErrorCode ec3; - SendRequest(ptr, ec3); - if (ec3) { - OnError(ec3); - } - } else { - SendRequestAsync(ptr); + TErrorCode ec3; + SendRequest(ptr, ec3); + if (ec3) { + OnError(ec3); } } } @@ -1159,7 +1151,7 @@ namespace { if (HttpConnManager()->Get(conn, Addr_->Id)) { DBGOUT("Use connection from cache"); Conn_ = conn; //thread magic - if (!conn->StartNextRequest(req, RequestSettings_.UseAsyncSendRequest)) { + if (!conn->StartNextRequest(req)) { continue; //if use connection from cache, ignore write error and try another conn } } else { @@ -1997,19 +1989,6 @@ namespace { return ret.Get(); } - THandleRef ScheduleAsyncRequest(const TMessage& msg, IOnRecv* fallback, TServiceStatRef& ss, bool useAsyncSendRequest) override { - THttpRequest::THandleRef ret(new THttpRequest::THandle(fallback, msg, !ss ? nullptr : new TStatCollector(ss))); - try { - auto requestSettings = T::RequestSettings(); - requestSettings.SetUseAsyncSendRequest(useAsyncSendRequest); - THttpRequest::Run(ret, msg, &T::Build, requestSettings); - } catch (...) { - ret->ResetOnRecv(); - throw; - } - return ret.Get(); - } - TStringBuf Scheme() const noexcept override { return T::Name(); } diff --git a/library/cpp/neh/http_common.h b/library/cpp/neh/http_common.h index a96f10a200..d19d1e4522 100644 --- a/library/cpp/neh/http_common.h +++ b/library/cpp/neh/http_common.h @@ -155,7 +155,6 @@ namespace NNeh { struct TRequestSettings { bool NoDelay = true; EResolverType ResolverType = EResolverType::ETCP; - bool UseAsyncSendRequest = false; TRequestSettings& SetNoDelay(bool noDelay) { NoDelay = noDelay; @@ -166,11 +165,6 @@ namespace NNeh { ResolverType = resolverType; return *this; } - - TRequestSettings& SetUseAsyncSendRequest(bool useAsyncSendRequest) { - UseAsyncSendRequest = useAsyncSendRequest; - return *this; - } }; struct TRequestGet { diff --git a/library/cpp/neh/neh.cpp b/library/cpp/neh/neh.cpp index dded731bb7..f669ea3757 100644 --- a/library/cpp/neh/neh.cpp +++ b/library/cpp/neh/neh.cpp @@ -104,18 +104,18 @@ namespace { const TString svcFail = "service status: failed"; } -THandleRef NNeh::Request(const TMessage& msg, IOnRecv* fallback, bool useAsyncSendRequest) { +THandleRef NNeh::Request(const TMessage& msg, IOnRecv* fallback) { TServiceStatRef ss; if (TServiceStat::Disabled()) { - return ProtocolForMessage(msg)->ScheduleAsyncRequest(msg, fallback, ss, useAsyncSendRequest); + return ProtocolForMessage(msg)->ScheduleRequest(msg, fallback, ss); } ss = GetServiceStat(msg.Addr); TServiceStat::EStatus es = ss->GetStatus(); if (es == TServiceStat::Ok) { - return ProtocolForMessage(msg)->ScheduleAsyncRequest(msg, fallback, ss, useAsyncSendRequest); + return ProtocolForMessage(msg)->ScheduleRequest(msg, fallback, ss); } if (es == TServiceStat::ReTry) { @@ -124,7 +124,7 @@ THandleRef NNeh::Request(const TMessage& msg, IOnRecv* fallback, bool useAsyncSe validator.Addr = msg.Addr; - ProtocolForMessage(msg)->ScheduleAsyncRequest(validator, nullptr, ss, useAsyncSendRequest); + ProtocolForMessage(msg)->ScheduleRequest(validator, nullptr, ss); } TNotifyHandleRef h(new TNotifyHandle(fallback, msg)); diff --git a/library/cpp/neh/neh.h b/library/cpp/neh/neh.h index e0211a7dff..b5e8cc291f 100644 --- a/library/cpp/neh/neh.h +++ b/library/cpp/neh/neh.h @@ -260,7 +260,7 @@ namespace NNeh { using THandleRef = TIntrusivePtr<THandle>; - THandleRef Request(const TMessage& msg, IOnRecv* fallback, bool useAsyncSendRequest = false); + THandleRef Request(const TMessage& msg, IOnRecv* fallback); inline THandleRef Request(const TMessage& msg) { return Request(msg, nullptr); |