diff options
author | dcherednik <dcherednik@ydb.tech> | 2023-01-25 19:48:11 +0300 |
---|---|---|
committer | dcherednik <dcherednik@ydb.tech> | 2023-01-25 19:48:11 +0300 |
commit | d0c58909d8d578d279ac18aabca3f97763121f77 (patch) | |
tree | 84f82a8f0a872fe1d6cba3d750f0f1a4a7a1b7ce /library/cpp | |
parent | d796d4eb742557a71d57046ca7fbaedec3ce60a9 (diff) | |
download | ydb-d0c58909d8d578d279ac18aabca3f97763121f77.tar.gz |
Do not start processing reques in case of client disconnect or client timeout.
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/grpc/server/grpc_request.h | 6 | ||||
-rw-r--r-- | library/cpp/grpc/server/grpc_request_base.h | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/library/cpp/grpc/server/grpc_request.h b/library/cpp/grpc/server/grpc_request.h index c4b7e9c040..4e869ef5f6 100644 --- a/library/cpp/grpc/server/grpc_request.h +++ b/library/cpp/grpc/server/grpc_request.h @@ -113,6 +113,10 @@ public: return FinishPromise_.GetFuture(); } + bool IsClientLost() const override { + return ClientLost_.load(); + } + TString GetPeer() const override { return TString(this->Context.peer()); } @@ -496,6 +500,7 @@ private: void OnFinish(EQueueEventStatus evStatus) { if (this->Context.IsCancelled()) { + ClientLost_.store(true); FinishPromise_.SetValue(EFinishStatus::CANCEL); } else { FinishPromise_.SetValue(evStatus == EQueueEventStatus::OK ? EFinishStatus::OK : EFinishStatus::ERROR); @@ -556,6 +561,7 @@ private: NThreading::TPromise<EFinishStatus> FinishPromise_; bool SkipUpdateCountersOnError = false; IStreamAdaptor::TPtr StreamAdaptor_; + std::atomic<bool> ClientLost_ = false; }; template<typename TIn, typename TOut, typename TService, typename TInProtoPrinter=google::protobuf::TextFormat::Printer, typename TOutProtoPrinter=google::protobuf::TextFormat::Printer> diff --git a/library/cpp/grpc/server/grpc_request_base.h b/library/cpp/grpc/server/grpc_request_base.h index 42b78ed7df..60b38805ed 100644 --- a/library/cpp/grpc/server/grpc_request_base.h +++ b/library/cpp/grpc/server/grpc_request_base.h @@ -116,6 +116,9 @@ public: //! Returns true if server is using ssl virtual bool SslServer() const = 0; + + //! Returns true if client was not interested in result (but we still must send response to make grpc happy) + virtual bool IsClientLost() const = 0; }; } // namespace NGrpc |