Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix cancellation of WinHttpHandler response stream reads - #8693

Merged
davidsh merged 3 commits into
dotnet:masterfrom
davidsh:responsestream_cancelread
May 20, 2016
Merged

davidsh merged 3 commits into
dotnet:masterfrom
davidsh:responsestream_cancelread

Conversation

@davidsh

@davidsh davidsh commented May 19, 2016

Copy link
Copy Markdown
Contributor

Reading from the response stream using ReadAsync() was ignoring the cancellation token passed in. To fix this, registered a delegate that will be called to dispose the WinHTTP request handle during pending I/O. This will cause the WinHTTP operation to cancel.

Added tests. For now, left them disabled to be resolved in issue #8692 next week. But wanted to get this fix in asap since it blocks partners for RTM.

Fixes #8662.

Reading from the response stream using ReadAsync() was ignoring the cancellation token passed in. To fix this, registered a delegate that will be called to dispose the WinHTTP request handle during pending I/O. This will cause the WinHTTP operation to cancel.

Added tests. For now, left them disabled to be resolved in issue #8692 next week. But wanted to get this fix in asap since it blocks partners for RTM.

Fixes #8662.
@davidsh

davidsh commented May 19, 2016

Copy link
Copy Markdown
Contributor Author

cc: @stephentoub @CIPop

// TODO: Issue #2165. Register callback on cancellation token to cancel WinHTTP operation.

// Register callback on cancellation token to cancel any pending WinHTTP operation.
if (token != CancellationToken.None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token.CanBeCanceled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

public class CancellationTest
{
// TODO: Issue #8692. Move this test server capability to Azure test server or Loopback server.
private const string FastHeadersSlowBodyHost = "winrtnet.corp.microsoft.com";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a publicly exposed endpoint? If not, do we want to make it publicly exposed?
Can we instead add the testing functionality to the Azure based servers?

@CIPop CIPop May 19, 2016 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there is an issue tracking the change: maybe we should remove the endpoint name and use an environment variable instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That endpoint is not publicly accessible.

I have an issue tracking changing this to the Azure test server (or even using Loopback server). So, I wasn't going to do the environment variable thing for this since it would be rolled into the current environment variable we have for the rest of the Azure tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an environment variable is best in this case: it achieves the same purpose internally and it doesn't expose intranet resource information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the DNS name of the internal server and replace it with a TODO. Since the tests are disabled right now w/ ActiveIssue, it will be ok. There is a GitHub issue tracking to re-enable this.

@stephentoub

Copy link
Copy Markdown
Member

Test Innerloop OSX Debug Build and Test please
Test Innerloop OSX Debug Build and Test please

@CIPop

CIPop commented May 19, 2016

Copy link
Copy Markdown

LGTM

@davidsh

davidsh commented May 19, 2016

Copy link
Copy Markdown
Contributor Author

Test Innerloop OSX Release Build and Test please

@davidsh
davidsh merged commit 7a55665 into dotnet:master May 20, 2016
@davidsh
davidsh deleted the responsestream_cancelread branch May 20, 2016 01:39
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…celread

Fix cancellation of WinHttpHandler response stream reads

Commit migrated from dotnet/corefx@7a55665
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinHttpResponseStream.ReadAsync() ignores cancellation token

5 participants