Skip to content

Conversation

@asweet-confluent
Copy link

@asweet-confluent asweet-confluent commented Sep 1, 2025

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Validation Steps Performed

telnet localhost 50000 multiple times.

When the relay is running in kernel debug mode, stay open after the client disconnects and continue accepting connections.
@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 02:27
@asweet-confluent asweet-confluent requested a review from a team as a code owner September 1, 2025 02:27
Copy link
Contributor

Copilot AI left a 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

Comment on lines +139 to +140
// Small delay to prevent tight loop on persistent errors
Sleep(100);
Copy link

Copilot AI Sep 1, 2025

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.

Copilot uses AI. Check for mistakes.
reinterpret_cast<HANDLE>(socket.get()), pipe.get(), 0x1000,
wsl::windows::common::relay::RelayFlags::LeftIsSocket);
}
catch (...)
Copy link

Copilot AI Sep 1, 2025

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.

Suggested change
catch (...)
catch (const wil::ResultException& ex)

Copilot uses AI. Check for mistakes.
@asweet-confluent
Copy link
Author

@microsoft-github-policy-service agree company="Confluent, Inc."

{
LOG_CAUGHT_EXCEPTION();

// Small delay to prevent tight loop on persistent errors
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

@benhillis benhillis left a comment

Choose a reason for hiding this comment

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

🕐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants