aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorand42 <and42@yandex-team.com>2025-02-28 10:29:14 +0300
committerand42 <and42@yandex-team.com>2025-02-28 11:28:36 +0300
commitb0a2365a3ba58c8b1c2ef256d2e061662b2b5900 (patch)
treeea0b19b5918dcf7fa86cc792ded36de9523e977e /library/cpp
parent54f08bc197a13725ddf51da1c507d9ea82bedd53 (diff)
downloadydb-b0a2365a3ba58c8b1c2ef256d2e061662b2b5900.tar.gz
return/make useful coordinator_new TestFetchGraphCancel
commit_hash:4721e3d84bd7a730a2fc5be4d0e42da14ef16c40
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/http/simple/http_client.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/library/cpp/http/simple/http_client.h b/library/cpp/http/simple/http_client.h
index 224be58a24..86a8cb4e99 100644
--- a/library/cpp/http/simple/http_client.h
+++ b/library/cpp/http/simple/http_client.h
@@ -267,11 +267,13 @@ TKeepAliveHttpClient::THttpCode TKeepAliveHttpClient::DoRequestReliable(const T&
const bool haveNewConnection = CreateNewConnectionIfNeeded();
const bool couldRetry = !haveNewConnection && i == 0; // Actually old connection could be already closed by server,
// so we should try one more time in this case.
- try {
- cancellation.Future().Subscribe([&](auto&) {
- Connection->Shutdown();
- });
+ TManualEvent cancellationEndEvent;
+ cancellation.Future().Subscribe([&](auto&) {
+ Connection->Shutdown();
+ cancellationEndEvent.Signal();
+ });
+ try {
Connection->Write(raw);
THttpCode code = ReadAndTransferHttp(*Connection->GetHttpInput(), output, outHeaders);
@@ -280,20 +282,29 @@ TKeepAliveHttpClient::THttpCode TKeepAliveHttpClient::DoRequestReliable(const T&
}
return code;
} catch (const TSystemError& e) {
+ if (cancellation.IsCancellationRequested()) {
+ cancellationEndEvent.WaitI();
+ cancellation.ThrowIfCancellationRequested();
+ }
Connection.Reset();
- cancellation.ThrowIfCancellationRequested();
if (!couldRetry || e.Status() != EPIPE) {
throw;
}
} catch (const THttpReadException&) { // Actually old connection is already closed by server
+ if (cancellation.IsCancellationRequested()) {
+ cancellationEndEvent.WaitI();
+ cancellation.ThrowIfCancellationRequested();
+ }
Connection.Reset();
- cancellation.ThrowIfCancellationRequested();
if (!couldRetry) {
throw;
}
} catch (const std::exception&) {
+ if (cancellation.IsCancellationRequested()) {
+ cancellationEndEvent.WaitI();
+ cancellation.ThrowIfCancellationRequested();
+ }
Connection.Reset();
- cancellation.ThrowIfCancellationRequested();
throw;
}
}