-
Notifications
You must be signed in to change notification settings - Fork 1.5k
wslrelay KD: stay open after first disconnect #13441
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
base: master
Are you sure you want to change the base?
wslrelay KD: stay open after first disconnect #13441
Conversation
When the relay is running in kernel debug mode, stay open after the client disconnects and continue accepting connections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the wslrelay tool to support persistent kernel debug mode by allowing the relay to stay open and accept multiple connections after the first client disconnects, rather than exiting after a single connection.
- Adds an infinite loop to continuously accept new socket connections
- Wraps connection handling in try-catch blocks with error logging and recovery
- Updates comments to reflect the new persistent behavior
| // Small delay to prevent tight loop on persistent errors | ||
| Sleep(100); |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fixed 100ms delay may be too aggressive for rapid reconnections in kernel debugging scenarios. Consider implementing exponential backoff or making the delay configurable to balance between responsiveness and resource usage.
| reinterpret_cast<HANDLE>(socket.get()), pipe.get(), 0x1000, | ||
| wsl::windows::common::relay::RelayFlags::LeftIsSocket); | ||
| } | ||
| catch (...) |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch-all exception handler may mask specific error conditions that should cause the relay to exit (e.g., pipe closure, critical system errors). Consider catching specific exceptions or checking for terminal error conditions.
| catch (...) | |
| catch (const wil::ResultException& ex) |
|
@microsoft-github-policy-service agree company="Confluent, Inc." |
| { | ||
| LOG_CAUGHT_EXCEPTION(); | ||
|
|
||
| // Small delay to prevent tight loop on persistent errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of persistent errors were you seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see any errors... Copilot added that and I figured it knew something I didn't. I can remove the sleep if you think it isn't needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'd suggest removing this try / catch entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
Co-authored-by: Copilot <[email protected]>
Summary of the Pull Request
When the relay is running in kernel debug mode, it accepts a single connection and then closes when that client disconnects. This change makes it stay open and continue accepting connections.
PR Checklist
Validation Steps Performed
telnet localhost 50000multiple times.