-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -101,7 +101,7 @@ try | |||||
| // Ensure that the other end of the pipe has connected. | ||||||
| wsl::windows::common::helpers::ConnectPipe(pipe.get(), (15 * 1000), {exitEvent.get()}); | ||||||
|
|
||||||
| // Bind, listen, and accept a connection on the specified port. | ||||||
| // Bind and listen on the specified port (once) | ||||||
| const wil::unique_socket listenSocket(WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_OVERLAPPED)); | ||||||
| THROW_LAST_ERROR_IF(!listenSocket); | ||||||
|
|
||||||
|
|
@@ -113,14 +113,33 @@ try | |||||
|
|
||||||
| THROW_LAST_ERROR_IF(listen(listenSocket.get(), 1) == SOCKET_ERROR); | ||||||
|
|
||||||
| const wil::unique_socket socket(WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_OVERLAPPED)); | ||||||
| THROW_LAST_ERROR_IF(!socket); | ||||||
|
|
||||||
| wsl::windows::common::socket::Accept(listenSocket.get(), socket.get(), INFINITE, exitEvent.get()); | ||||||
|
|
||||||
| // Begin the relay. | ||||||
| wsl::windows::common::relay::BidirectionalRelay( | ||||||
| reinterpret_cast<HANDLE>(socket.get()), pipe.get(), 0x1000, wsl::windows::common::relay::RelayFlags::LeftIsSocket); | ||||||
| for (;;) | ||||||
| { | ||||||
| if (exitEvent && WaitForSingleObject(exitEvent.get(), 0) == WAIT_OBJECT_0) | ||||||
| { | ||||||
| break; | ||||||
| } | ||||||
|
|
||||||
| const wil::unique_socket socket(WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_OVERLAPPED)); | ||||||
| THROW_LAST_ERROR_IF(!socket); | ||||||
|
|
||||||
| try | ||||||
| { | ||||||
| wsl::windows::common::socket::Accept(listenSocket.get(), socket.get(), INFINITE, exitEvent.get()); | ||||||
|
|
||||||
| // Begin the relay for this connection | ||||||
| wsl::windows::common::relay::BidirectionalRelay( | ||||||
| reinterpret_cast<HANDLE>(socket.get()), pipe.get(), 0x1000, | ||||||
| wsl::windows::common::relay::RelayFlags::LeftIsSocket); | ||||||
| } | ||||||
| catch (...) | ||||||
|
||||||
| catch (...) | |
| catch (const wil::ResultException& ex) |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.