Fixed WinHTTP failfast caused by premature cancellation (#6637)

This commit is contained in:
Larry Osterman 2025-06-30 10:52:32 -07:00 committed by GitHub
parent 18a1d27d33
commit a14e3d5ee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 2 deletions

View File

@ -8,6 +8,8 @@
### Bugs Fixed
Fixed WinHTTP FailFast exception raised when a request is cancelled before the request is actually sent on the wire.
### Other Changes
## 1.16.0-beta.1 (2025-06-05)

View File

@ -28,6 +28,7 @@
// Define the class name that reads from ConnectionPool private members
namespace Azure { namespace Core { namespace Test {
class CurlConnectionPool_connectionPoolTest_Test;
class CurlConnectionPool_DISABLED_connectionPoolTest_Test;
class CurlConnectionPool_uniquePort_Test;
class CurlConnectionPool_connectionClose_Test;
class SdkWithLibcurl_globalCleanUp_Test;
@ -47,6 +48,7 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
#if defined(_azure_TESTING_BUILD)
// Give access to private to this tests class
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
friend class Azure::Core::Test::CurlConnectionPool_DISABLED_connectionPoolTest_Test;
friend class Azure::Core::Test::CurlConnectionPool_uniquePort_Test;
friend class Azure::Core::Test::CurlConnectionPool_connectionClose_Test;
friend class Azure::Core::Test::SdkWithLibcurl_globalCleanUp_Test;

View File

@ -22,6 +22,7 @@
// Define the class name that reads from ConnectionPool private members
namespace Azure { namespace Core { namespace Test {
class CurlConnectionPool_connectionPoolTest_Test;
class CurlConnectionPool_DISABLED_connectionPoolTest_Test;
class SdkWithLibcurl_globalCleanUp_Test;
}}} // namespace Azure::Core::Test
#endif
@ -44,6 +45,7 @@ namespace Azure { namespace Core { namespace Http {
// Give access to private to this tests class
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
friend class Azure::Core::Test::SdkWithLibcurl_globalCleanUp_Test;
friend class Azure::Core::Test::CurlConnectionPool_DISABLED_connectionPoolTest_Test;
#endif
private:
/**

View File

@ -530,8 +530,11 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
Azure::Core::Context const& context,
Azure::DateTime::duration const& pollDuration)
{
// Before doing any work, check to make sure that the context hasn't already been cancelled.
context.ThrowIfCancelled();
//
// Note that we cannot check for cancellation before calling `initiateAction` because it's
// possible that the `initiateAction` call is a call to `WinHttpSendRequest` which establishes
// the SendContext.
//
// By definition, there cannot be any actions outstanding at this point because we have not
// yet called initiateAction. So it's safe to reset our state here.

View File

@ -41,7 +41,11 @@ namespace Azure { namespace Core { namespace Test {
/*********************** Unique Tests for Libcurl ********************************/
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
#if _azure_DISABLE_HTTP_BIN_TESTS
TEST(CurlConnectionPool, DISABLED_connectionPoolTest)
#else
TEST(CurlConnectionPool, connectionPoolTest)
#endif
{
{
std::lock_guard<std::mutex> lock(

View File

@ -446,7 +446,11 @@ namespace Azure { namespace Core { namespace Test {
CheckBodyFromBuffer(*response, expectedResponseBodySize);
}
#if _azure_DISABLE_HTTP_BIN_TESTS
TEST_P(TransportAdapter, DISABLED_cancelTransferUpload)
#else
TEST_P(TransportAdapter, cancelTransferUpload)
#endif
{
Azure::Core::Url host(AzureSdkHttpbinServer::Put());
Azure::Core::Context cancelThis;