Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Fixed and issue where WinHttp transport was not closing correctly in case of request timeout.

### Other Changes

- Move the connection back to the connection pool when HTTP error 404 was received. This may improve the performance of a multithreaded application when libcurl transport adapter is being used. (A community contribution, courtesy of _[mchelnokov](https://github.com/mchelnokov)_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
WinHttpTransportOptions const& options);

~WinHttpRequest();

void MarkRequestHandleClosed() { m_requestHandleClosed = true; };
void Upload(Azure::Core::Http::Request& request, Azure::Core::Context const& context);
void SendRequest(Azure::Core::Http::Request& request, Azure::Core::Context const& context);
void ReceiveResponse(Azure::Core::Context const& context);
Expand Down
14 changes: 6 additions & 8 deletions sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,17 +528,15 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
// destroyed *after* lock is destroyed, ensuring that the event is not set to the signalled
// state before the lock is released.
auto scope_exit{m_actionCompleteEvent.SetEvent_scope_exit()};
std::unique_lock<std::mutex> lock(m_actionCompleteMutex);
m_stowedErrorInformation = stowedErrorInformation;
m_stowedError = stowedError;
}
else
{
Log::Write(
Logger::Level::Verbose,
"Received error while closing: " + std::to_string(stowedError));
Logger::Level::Verbose, "Received error while closing: " + std::to_string(stowedError));
}

std::unique_lock<std::mutex> lock(m_actionCompleteMutex);
m_stowedErrorInformation = stowedErrorInformation;
m_stowedError = stowedError;
}

DWORD WinHttpAction::GetStowedError()
Expand Down Expand Up @@ -574,10 +572,9 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
{
return;
}

WinHttpAction* httpAction = reinterpret_cast<WinHttpAction*>(dwContext);
try
{
WinHttpAction* httpAction = reinterpret_cast<WinHttpAction*>(dwContext);
httpAction->OnHttpStatusOperation(
hInternet, internetStatus, statusInformation, statusInformationLength);
}
Expand All @@ -588,6 +585,7 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
Logger::Level::Error,
"Request Failed Exception Thrown: " + std::string(rfe.what()) + rfe.Message);
WinHttpCloseHandle(hInternet);
httpAction->m_httpRequest->MarkRequestHandleClosed();
}
catch (std::exception const& ex)
{
Expand Down