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

use background thread to wait for address changes on OSX#41768

Merged
wfurt merged 3 commits intodotnet:masterfrom
wfurt:addressChange_41740
Oct 16, 2019
Merged

use background thread to wait for address changes on OSX#41768
wfurt merged 3 commits intodotnet:masterfrom
wfurt:addressChange_41740

Conversation

@wfurt
Copy link
Member

@wfurt wfurt commented Oct 14, 2019

we should not block process exit.

fixes #41740

@wfurt wfurt requested review from a team and stephentoub October 14, 2019 19:14
@wfurt wfurt self-assigned this Oct 14, 2019
// and forces quit even when foreground threads are running.
NetworkChange.NetworkAddressChanged += _addressHandler;
{
};
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. I know we spoke about it offline, but seeing it now I realize this could negatively interact with other tests. Do any other tests validate the behavior when going from zero to one handlers, validate the behavior when the last handler is removed, etc.?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not see any. All the tests are primitive in sense that they only verify that handler can be set but they do not test actual address changes as that is difficult to do in CI.

// Register without unregistering.
// This should not block process exit. If it does, this test will pass
// but we would fail to exit test run at the end.
// We cannot test this via RemoteInvoke() as that call System.Exit()
Copy link
Member

@jkotas jkotas Oct 15, 2019

Choose a reason for hiding this comment

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

Suggested change
// We cannot test this via RemoteInvoke() as that call System.Exit()
// We cannot test this via RemoteInvoke() as that calls Environment.Exit()

Copy link
Member

Choose a reason for hiding this comment

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

Indeed it even says

                // Use Exit rather than simply returning the exit code so that we forcibly shut down
                // the process even if there are foreground threads created by the operation that would
                // end up keeping the process alive potentially indefinitely.

Copy link
Member

Choose a reason for hiding this comment

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

I know I added this explicitly a while back, but I can't remember now why. Ideally there wouldn't be any foreground threads and this logic could go away. Worth looking into subsequently.

@@ -181,6 +181,7 @@ private static unsafe void CreateAndStartRunLoop()
}
}
s_runLoopThread = new Thread(RunLoopThreadStart);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It is not necessary to keep s_runLoopThread in a static. It is never used for anything. This can be a local variable.

@wfurt wfurt merged commit 08bf1fe into dotnet:master Oct 16, 2019
@wfurt wfurt deleted the addressChange_41740 branch October 16, 2019 05:10
danmoseley pushed a commit to danmoseley/corefx that referenced this pull request Oct 21, 2019
* use background thread to wait for address changes on OSX

* remove RemoteExecutor

* update comment
danmoseley added a commit that referenced this pull request Oct 21, 2019
…1960)

* use background thread to wait for address changes on OSX

* remove RemoteExecutor

* update comment
danmoseley pushed a commit to danmoseley/corefx that referenced this pull request Nov 4, 2019
* use background thread to wait for address changes on OSX

* remove RemoteExecutor

* update comment
@karelz karelz added this to the 5.0 milestone Nov 9, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…fx#41768)

* use background thread to wait for address changes on OSX

* remove RemoteExecutor

* update comment


Commit migrated from dotnet/corefx@08bf1fe
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.

NetworkAddressChanged event hangs process on Mac

5 participants