wslrelay KD: stay open after first disconnect#13441
wslrelay KD: stay open after first disconnect#13441asweet-confluent wants to merge 2 commits intomicrosoft:masterfrom
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.
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); |
There was a problem hiding this comment.
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 (...) |
There was a problem hiding this comment.
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.
What kind of persistent errors were you seeing?
There was a problem hiding this comment.
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.
Yes I'd suggest removing this try / catch entirely.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.