Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Foundation] Fix NSUrlSessionHandler thread issues. #1889

Conversation

mandel-macaque
Copy link
Member

Do not deal with the configuration in the instance constructor. We do
not need to do it for every instance AND it is racy.

This fixes bug #53461.

Do not deal with the configuration in the instance constructor. We do
not need to do it for every instance AND it is racy.
@mandel-macaque
Copy link
Member Author

To test the fix, please create an app like the following one: https://gist.github.com/chamons/793789e4bc01970c54d63bbe55777abf

And used https://gist.github.com/chamons/67a3d39080bb3c9fa598f593fcfab919 to execute it until we have a crash. We should not have any runtime related crashed (you might get network ones related, for example, running the app with no connection to the internet)

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

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

I don't think it's fine.

It means changing ServicePointManager.SecurityProtocol to a new value will never have any impact after NSUrlSessionHandler static ctor has been executed.

Please check this on .NET but I'm fairly sure you can change that setting and have further HttpClient instance honor this value.

@marek-safar
Copy link
Contributor

I think correct fix is to use https://github.com/mono/mono/blob/master/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs#L462 value only and when not set use XM default which is whatever value you choose.
You should not touch/read ServicePointManager.SecurityProtocol as that's used by webrequest only.

@monojenkins
Copy link
Collaborator

Build success

@spouliot spouliot added the do-not-merge Do not merge this pull request label Mar 20, 2017
spouliot added a commit to spouliot/xamarin-macios that referenced this pull request Mar 20, 2017
…rotocol is set

During the investigation for a System.Configuration race in bug #53461 [1]
it was found that we did not pass the computed value for
`TLSMinimumSupportedProtocol` based on `ServicePointManager.SecurityProtocols`
to the `NSUrlSession`, in effect allowing what the OS does, by default,
and not what the application requested.

This replace an earlier attempt to fix the race in PR xamarin#1889

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=53461
[2] xamarin#1889
@spouliot
Copy link
Contributor

PR 1890 fix another issue found while investigating bug #53461. However this is not related the the race, which happens in the BCL.

@spouliot spouliot closed this Mar 20, 2017
spouliot added a commit that referenced this pull request Mar 22, 2017
…rotocol is set (#1890)

During the investigation for a System.Configuration race in bug #53461 [1]
it was found that we did not pass the computed value for
`TLSMinimumSupportedProtocol` based on `ServicePointManager.SecurityProtocols`
to the `NSUrlSession`, in effect allowing what the OS does, by default,
and not what the application requested.

This replace an earlier attempt to fix the race in PR #1889

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=53461
[2] #1889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge Do not merge this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants