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

update proxy setting on registry changes #103364

Merged
merged 15 commits into from
Jul 8, 2024
Merged

update proxy setting on registry changes #103364

merged 15 commits into from
Jul 8, 2024

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Jun 12, 2024

update proxy configuration on registry changes on Windows. That for example allows to start Fiddler and start capturing traffic without need to restart the process. It can of course also pick changes user does directly via Setting widget.

fixes #46910 and contributes to #95252.
It does not implement new API #95252 proposed but it seems to fix the use case it is describing.
Perhaps it can be closed as well @ManickaP?

Note that this does not apply to existing connections. e.g. the updated setting applies only when new connection is needed. If that is problem, it can perhaps be mitigated by either idea or absolute time on connection pool..

It also cannot detect changes to PAC or cases when something changes inside "auto" but there is no registry change.

@wfurt wfurt added this to the 9.0.0 milestone Jun 12, 2024
@wfurt wfurt requested a review from a team June 12, 2024 18:30
@wfurt wfurt self-assigned this Jun 12, 2024
proxy.UpdateConfiguration();
}

private void UpdateConfiguration()
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for multiple UpdateConfiguration() callbacks to run in parallel if there are multiple registry edits done in sequence?

We may want to ensure that the most recent UpdateConfiguration wins in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

The notifications do not have content. e.g. I think it would work just fine as long as the updates would finish in sequence they started.

The problem may be if let say there are part A and B. B get updated and that starts update reading old A. A updates, new config update starts and finishes before first update is done. The first task may be winner writing older configuration.

If we feel this is concern we have several options. We can simply lock the proxy object in the callback. Since that is only one place the only contention would be registry notification. But I'm not sure if that can cause any troubles for the thread pool. We can also update ThreadPool.RegisterWaitForSingleObject to fire only once but then we need new registration every time and I don't know how expensive that is (relative to all the other processing) I was also originally thinking about swapping the order of RegNotifyChangeKeyValue and UpdateConfiguration but I think we may miss some notifications in that case.

Copy link
Member

Choose a reason for hiding this comment

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

I do not see a problem with taking the lock.

@ManickaP
Copy link
Member

It does not implement new API #95252 proposed but it seems to fix the use case it is describing.
Perhaps it can be closed as well @ManickaP?

We didn't want to implement new API, we wanted to change the behavior which at the moment is fetch once per whole process lifetime. So we also talked about rechecking environment variables every time you call GetSystemProxy, which this PR doesn't handle AFAICT.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@wfurt
Copy link
Member Author

wfurt commented Jun 21, 2024

all tests failures are known issues. This is ready for another review round.

@rzikm rzikm self-requested a review July 2, 2024 16:00
Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM

@wfurt wfurt merged commit e71e0f4 into dotnet:main Jul 8, 2024
79 of 83 checks passed
@wfurt wfurt deleted the proxyUpdate branch July 8, 2024 04:22
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
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.

HttpClient.DefaultProxy should respect IE proxy changes
5 participants