[PR #5303] [MERGED] Don't wait for a connection to finish when a control is closed #26248

Open
opened 2026-01-31 09:14:54 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5303
Author: @zadjii-msft
Created: 4/9/2020
Status: Merged
Merged: 4/10/2020
Merged by: @undefined

Base: masterHead: dev/migrie/b/1996-tab-closing-not-speed-enough


📝 Commits (8)

  • dc068f7 This is dirty but I think I've got #1996 fixed
  • e267ad4 make this code way cleaner, add comments
  • fcf98cb typos
  • 58704ba Merge remote-tracking branch 'origin/master' into dev/migrie/b/1996-tab-closing-not-speed-enough
  • 4017b4b Uhg whatever I was doing before definitely isn't always working today
  • 4d3cfd3 turns out all those other changes were bad, and this is all that's needed
  • b4ff259 add comments to explain this
  • 4621a2b I'm literally incapable of hitting Ctrl+S

📊 Changes

2 files changed (+28 additions, -5 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+26 -5)
📝 src/cascadia/TerminalControl/TermControl.h (+2 -0)

📄 Description

Summary of the Pull Request

When a pane is closed by a connection, we want to wait until the connection is actually Closed before we fire the actual Closed event. If the connection didn't close gracefully, there are scenarios where we want to print a message to the screen.

However, when a pane is closed by the UI, we don't really care to wait for the connection to be completely closed. We can just do it whenever. So I've moved that call to be on a background thread.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Previously we'd wait for the connection to close synchronously when closing tabs or panes. For misbehaving applications like ssh.exe, that could result in the Close needing to WaitForSingleObject on the UI thread. If the user closed the tab / pane either with a keybinding or with some other UI element, they don't really care to see the error message anymore. They just want the pane closed. So there's no need to wait for the actual connection to close - the app can just continue on with whatever it was doing.

Validation Steps Performed

Messed around with closing tabs, panes, tabs with many panes, the entire window. Did this with keybindings, or by clicking on the 'x' on the tab, the 'x' on the window, or using middle-click.

I'm always scared of things like this, so there's a 50% chance this makes things horribly worse.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5303 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/9/2020 **Status:** ✅ Merged **Merged:** 4/10/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/b/1996-tab-closing-not-speed-enough` --- ### 📝 Commits (8) - [`dc068f7`](https://github.com/microsoft/terminal/commit/dc068f74c1b01d91c174b3733d7f10755dfa8ee2) This is dirty but I think I've got #1996 fixed - [`e267ad4`](https://github.com/microsoft/terminal/commit/e267ad4995de063551c88847abcf432226dd1d6b) make this code way cleaner, add comments - [`fcf98cb`](https://github.com/microsoft/terminal/commit/fcf98cb866e456af5d50ea6cddd6aa9c4a7087d1) typos - [`58704ba`](https://github.com/microsoft/terminal/commit/58704ba83b8a350ece9209b424f91fb6e0310618) Merge remote-tracking branch 'origin/master' into dev/migrie/b/1996-tab-closing-not-speed-enough - [`4017b4b`](https://github.com/microsoft/terminal/commit/4017b4b2b369c300f6a9ef838c0a41916ba4e010) Uhg whatever I was doing before definitely isn't always working today - [`4d3cfd3`](https://github.com/microsoft/terminal/commit/4d3cfd3d79f5498e06f04b0bbc48c4739225fb3b) turns out all those other changes were bad, and this is all that's needed - [`b4ff259`](https://github.com/microsoft/terminal/commit/b4ff2592b229c378db34d51c2f2324f85ceb2b30) add comments to explain this - [`4621a2b`](https://github.com/microsoft/terminal/commit/4621a2b1cdaf146ec50e956fc1b805e56939b861) I'm literally incapable of hitting Ctrl+S ### 📊 Changes **2 files changed** (+28 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+26 -5) 📝 `src/cascadia/TerminalControl/TermControl.h` (+2 -0) </details> ### 📄 Description ## Summary of the Pull Request When a pane is closed by a connection, we want to wait until the connection is actually `Closed` before we fire the actual `Closed` event. If the connection didn't close gracefully, there are scenarios where we want to print a message to the screen. However, when a pane is closed by the UI, we don't really care to wait for the connection to be completely closed. We can just do it whenever. So I've moved that call to be on a background thread. ## PR Checklist * [x] Closes #1996 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments Previously we'd wait for the connection to close synchronously when closing tabs or panes. For misbehaving applications like `ssh.exe`, that could result in the `Close` needing to `WaitForSingleObject` _on the UI thread_. If the user closed the tab / pane either with a keybinding or with some other UI element, they don't really care to see the error message anymore. They just want the pane closed. So there's no need to wait for the actual connection to close - the app can just continue on with whatever it was doing. ## Validation Steps Performed Messed around with closing tabs, panes, tabs with many panes, the entire window. Did this with keybindings, or by clicking on the 'x' on the tab, the 'x' on the window, or using middle-click. I'm always scared of things like this, so there's a 50% chance this makes things horribly worse. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:14:54 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26248