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

WinHttpHandler uses async WinHTTP patterns - #3867

Merged
davidsh merged 1 commit into
dotnet:masterfrom
davidsh:winhttphandler_async
Oct 16, 2015
Merged

davidsh merged 1 commit into
dotnet:masterfrom
davidsh:winhttphandler_async

Conversation

@davidsh

@davidsh davidsh commented Oct 14, 2015

Copy link
Copy Markdown
Contributor

This is a large PR and addresses work item #3000. I apologize for not being able to structure it in a series of smaller commits.

The bulk of this PR is switching WinHttpHandler to use the async pattern of calling WinHTTP APIs. This involved a significant restructuring of the code. As part of that, I split up the large WinHttpHandler class into multiple, smaller, helper classes.

While the intent of using async WinHTTP calls is better performance and cancel-ability, this PR has not been fully optimized yet. Due to the schedule of RC1 code complete next week, it's important that this PR get in and get mileage on it in the next few weeks.

There are several TODO items that will be done in later PR's. There is still work being tracked in #2165 for various follow-up items. For example, re-conciling the best SafeHandle pattern to use for WinHTTP between WebSockets.Client and WinHttpHandler.

I'm currently using a simple Debug.WriteLine for verbose debug logging which can be turned on/off via environment variable. I plan to switch this to System.Net ETW trace loggers in the next commit and/or PR. But the logging has proved very useful in diagnosing issues.

Please provide feedback. Depending on the feedback, some of it will be marked as follow-up items for future PRs.

@davidsh

davidsh commented Oct 14, 2015

Copy link
Copy Markdown
Contributor Author

@CIPop @stephentoub PTAL
/cc: @SidharthNabar @josguil

@ghost

ghost commented Oct 15, 2015

Copy link
Copy Markdown

Test this please (a socket test was failing on linux debug: gist with jenkins URL)

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.

Can you make these readonly, or at least the cache lock? Also, if you're not going to be handing out the _credentialCache to anyone, you might consider just locking on it. And if you wanted to be able to easily change that decision in the future, you could do:

private object CredentialCacheLock { get { return _credentialCache; } }

and then lock on CredentialCacheLock.

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 make them both readonly.

I didn't make them as properties because I was worried about the overhead of using getter's instead of just accessing the field itself. Is there an overhead to worry about or will the compiler be smart and inline?

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.

They don't need to be properties; the only reason I suggested it for the lock was so that you could avoid allocating another object but still have a nice "lock" name for whatever object you end up using as the lock. That said, yes, the JIT should inline such simple getters.

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.

Thx for the clarification. I will leave them for now as 2 separate things but marked as readonly. As this evolves, I'll consider the suggestions for further optimizations.

@stephentoub

Copy link
Copy Markdown
Member

Left a variety of comments, but overall looks good.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please add an issue # for all TODOs in the PR.

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 have issue #'s for all TODO's.

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.

9 participants