After looking at some asserts and crashes in the performance/stress tests with this PR, I discovered that the order of receiving HANDLE_CLOSING callbacks is not always the same as the order in which the handles are closed. This was causing the state object to be unpinned at the wrong time depending on async race conditions.
Modified the pin/unpin design to be cleaner and use interlocks to increment/decrement the number of handles associated with the callback (at most there are two - request and websocket handles).
Commit migrated from https://github.com/dotnet/corefx/commit/b2fb65865bc9dfb9af729faca38f4bccb1b7b31e
The Windows implementation of WebSockets.Client leaks the WinHttpWebSocketState object. This object was being pinned by `GCHandle.Alloc(this)` in the contructor. And it was never freed.
This object needs to be pinned during the WebSocket lifecycle because the address of the object is passed to native WinHTTP and used as the context value during callbacks. However, it needs to be manually freed at the proper time after all WinHTTP callbacks are done via closing down the handles.
This fix adds Pin() and Unpin() methods to WinHttpWebSocketState and calls them at appropriate times. While fixing this I discovered other places where the object might be left as pinned. The current logic relies on WinHTTP calling the callback with HANDLE_CLOSING before the object would get unpinned. But since the object is pinned very early on, it's possible due to unexpected errors, that the wiring of the WinHTTP callback never gets done. And thus, the object would never have been unpinned. This fix delays the pinning of the object until the right time where it is assured that the WinHTTP callback wiring has been completed.
This logic is now similar to the state handling in WinHttpHandler. There is still a work item dotnet/corefx#2501 to merge these design implementations and share code in the future.
Fixesdotnet/corefx#3256.
Commit migrated from https://github.com/dotnet/corefx/commit/73eca63458ba8f6ed121cc19813b907e359a67c9
Originally the goal was to tag the configurations with OSGroup=Windows_NT
if they were only applicable on that OS. However there is nothing particular
to that OS for most of them and they can build and run on an OS that supports
the managed dependencies.
More importantly we want to enable people to build IL only packages on any
OS and not force them to have a separate windows only package for things targeting
netcore50/netcore50aot. As an example System.AppContext recently introduced
an IL only package that can and should build fine on other OS's.
Commit migrated from https://github.com/dotnet/corefx/commit/3455f80483fbe89894f8ba69eafa0641bc78ecd8
Port remaining websocket client tests dealing with close handshake semantics including "server initiated" close handshakes.
Switch networking test servers to the newer Azure Cloud Service servers which work better with websocket close handshakes.
Commit migrated from https://github.com/dotnet/corefx/commit/e2e14e2f1abd1bfce0b0cae4b2e85cfe659d9074
Substituting Logging calls to EventSource calls, or calls to
LoggingHash.
Formatting Changes
Fixing Aligment, and casing.
Changing Dump methods log the hash of the object calling it instead of the method
After some discussion, it was decided that it is more useful to log the
object where the dump happens, than the method. Doing the necessary
changes for it.
Changing usage of "this" to [CallerMemberName]
Instead of using this to know who called the logging method, using
[CallerMemberName] as an attribute to the parameter to fill that
information.
Adding a TODO item.
Making a note to not change NetEventSource or it can break.
Missing Underscore
Adding missing underscore in _wsaBuffer
Commit migrated from https://github.com/dotnet/corefx/commit/f39502ef910c90ba1e67d787df98b627d39ba6cc
This these .builds files were updated and generated from a script
based on the configurations defined in the matching csproj files.
This updates the builds files to specify OSGroup and TargetGroup
as metadata instead of using AdditionalProperties and also sorts them by
TargetGroup followed by OSGroup.
Commit migrated from https://github.com/dotnet/corefx/commit/95efe37475916016a5fc6ee6f0ba584d990c4196
This add a default configuration before the Import of dirs.props
for any projects that don't have Debug as the default configuration.
Removed Configuration and Platform properties set after dirs.props
as they would have no affect and just cause confusion.
Removed OutputType=Library property as it isn't necessary.
Commit migrated from https://github.com/dotnet/corefx/commit/9e1da13cf6d5ff4b37b1867beb3411a2fe61da6a
These facade project files were generated using a porting tool I wrote,
which examined some information from our internal build and created
appropriate project files. I have also re-generated all of the .builds
files so that they import the facade projects in the correct manner.
Commit migrated from https://github.com/dotnet/corefx/commit/58e2f6e862060039e1ebad727d75c87703fdb2f2
Switching System.Net Win contracts to use code in the Open partition.
Creating individual implementations for System.Net contracts for Win.
Removing System.Private.Networking (partial, requires a second check-in due to TFS limitations).
Removing System.Private.Networking.Build.
Removing System.Net.Common.
Updating ToF tests.
Reactivating all ToF tests for System.Net (validated on private builds).
Porting remaining UnitTests to GitHub.
Creating packages for System.Net.Utilities for Unix.
[tfs-changeset: 1554743]
Commit migrated from https://github.com/dotnet/corefx/commit/96ef10191969d8216d538e9a2a25222661b83683
* Port some of the ToF ClientWebSocket tests that talk to a real websocket server
* Cleanup naming of existing tests to conform to System.Net test method naming
* Skip tests if not supported on platform. Specifically, these tests were failing
on Win7 since Win7 does not support WinHttp WebSockets. We haven't really noticed this
failing since the CI doesn't yet run Win7 tests (issue dotnet/corefx#4468)
I plan to port the remainder of the ToF websocket related tests in a subsequent PR.
Commit migrated from https://github.com/dotnet/corefx/commit/5006756101cab2edb9bb40590542d7a3df15f0cc
A change was made to DNX to no longer restore project.jsons
that are in nested folders. This caused my batch update to miss
a number of tests and reference assembly projects.
This fixes the stale lock files, but restore is still broken.
[tfs-changeset: 1540448]
Commit migrated from https://github.com/dotnet/corefx/commit/3622cccc1b22fa1947a72d5126b59864e9d2fd0d
We need a new DNX to understand the latest packages.
We also need to move all "dotnet" projects to use dotnetX.X (generations)
now that the packages no longer have "dotnet" assets.
The new version of DNX dropped support for the aspnetcore
so I needed to update a few projects/packages that depended
on old package versions that had this moniker.
[tfs-changeset: 1540388]
Commit migrated from https://github.com/dotnet/corefx/commit/38f8d7a3ca1ee819c2b8eabb1c07ee4e99683c97