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

(A better) Refactoring of how connection restarting is handled #15240

Merged
merged 15 commits into from
Apr 28, 2023

Conversation

zadjii-msft
Copy link
Member

A different take on #14548.

We didn't love that a connection could transition back in the state diagram, from Closed -> Start. That felt wrong. To remedy this, we're going to allow the ControlCore to...

ASK the app to restart its connection. This is a much more sensible approach, than leaving the ConnectionInfo in the core and having the core do the restart itself. That's mental.

Cleanup from #14060

Closes #14327

Obsoletes #14548

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. labels Apr 26, 2023

// Fire off a connection state changed notification, to let our hosting
// app know that we're in a different state now.
if (newConnection.State() != _connection.State())
Copy link
Member

Choose a reason for hiding this comment

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

_connection may be nullptr here.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

src/cascadia/TerminalControl/ControlCore.cpp Outdated Show resolved Hide resolved
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

I also noticed Dustin's comment. But LGTM otherwise.

Comment on lines +1110 to +1114
if (!_IsLeaf())
{
return;
}
_RestartTerminalRequestedHandlers(shared_from_this());
Copy link
Member

Choose a reason for hiding this comment

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

That seems a little round-about. 😅

Comment on lines 301 to 304
if (replacing)
{
_connection.Start();
}
Copy link
Member

Choose a reason for hiding this comment

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

(A theoretical concern:) If the new connection is already started, this will re-start it. Either, we should replace if (replacing) with if (_connection.State() != Started), or make sure that all implementations of Start() are robust against calling it multiple times. I think the former is better. If you did that, you can replace the other if (replacing) above with a simpler if (_connection) as well... I think. 🤔

src/cascadia/TerminalControl/TermControl.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/ControlCore.cpp Outdated Show resolved Hide resolved
{
_connection.Close();
Copy link
Member

Choose a reason for hiding this comment

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

This isn't our job here - I know that we Start() it later because we want to maintain consistency (so that the first output gets written to the right place), but if I detach a connection and hold a reference to it i would expect it to keep running.

The dtor can handle it for us if TC was holding the last reference.

Copy link
Member

Choose a reason for hiding this comment

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

actually, maybe we should move all Start() lifecycle ownership up into the component that GIVES us a connection.

Do we have a race on Initialized() vs Connection Start?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 27, 2023
DHowett added a commit that referenced this pull request Apr 27, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 28, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Apr 28, 2023
@DHowett DHowett enabled auto-merge (squash) April 28, 2023 20:00
@DHowett DHowett merged commit 0d6642a into main Apr 28, 2023
@DHowett DHowett deleted the dev/migrie/f/more-sane-connection-restarting branch April 28, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. zBugBash-Consider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code Health: follow ups from connection restarting
3 participants