diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 9160ff53e..7b9b5a99c 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -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) diff --git a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp index 4248ff25a..cbc087691 100644 --- a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp @@ -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; diff --git a/sdk/core/azure-core/src/http/curl/curl_session_private.hpp b/sdk/core/azure-core/src/http/curl/curl_session_private.hpp index 19eca51ca..7866a302c 100644 --- a/sdk/core/azure-core/src/http/curl/curl_session_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_session_private.hpp @@ -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: /** diff --git a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp index 410aa1220..5dcc0b488 100644 --- a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp +++ b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp @@ -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. diff --git a/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp b/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp index 281abaedf..19166e05f 100644 --- a/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_connection_pool_test.cpp @@ -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 lock( diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp index 776e4d055..ef122cc17 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base_test.cpp @@ -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;