Skip to content
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

Fix Unix Sockets on Windows #4479

Merged
merged 5 commits into from
Nov 25, 2024
Merged

Conversation

brian-mcnamara
Copy link
Contributor

@brian-mcnamara brian-mcnamara commented Nov 13, 2024

Subsystem
Network

Motivation
I am working with Unix domain sockets (client), and using ktor to communicate between processes via the socket. When I switched to testing on Windows, I noticed that when I tried to connect to the socket, it would instantly close. Upon further digging, the difference appears to be in SocketImpl, upon calling channel.connect, Windows (at least my machine) returns false, which brings it into a blocking condition until the connection is connected. However, as part of that block, the selfConnect would return true since both local and remote addresses are not of type InetSocketAddress, which results in the return condition returning true, and thus closing the connection. leading to a connection closed exception

Solution
Since there was a comment which indicated that selfConnect was for TCP over the network, I simply added a check to validate the local and remote are both not InetSocketAddress, which would be the case for Unix sockets.

Note:
TCPSocketTest.testEchoOverUnixSockets was failing without this change on my machine (which I had to dig around to figure out how to switch the runtime JVM version so the test would actually run. Note for anyone in the future, the jvm version is set in JvmConfig.kt, see Test.configureJavaLauncher extension function)

@e5l e5l self-requested a review November 14, 2024 09:51
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

Hey @brian-mcnamara, thanks for the PR!
Could you please check the compilation error for the task linkDebugTestMingwX64?

@brian-mcnamara
Copy link
Contributor Author

Hey @e5l , thanks for taking a look. Can we retry rerunning CI? I'm seeing no reason this change would cause a compile error

@brian-mcnamara
Copy link
Contributor Author

brian-mcnamara commented Nov 15, 2024

Took a look at the failures, unless I am reading teamcity wrong, the test histroy for the failed tests are also failing on main

@e5l
Copy link
Member

e5l commented Nov 25, 2024

Hey @brian-mcnamara, thank you for the PR! LGTM

@e5l e5l merged commit db760a2 into ktorio:main Nov 25, 2024
13 checks passed
@brian-mcnamara brian-mcnamara deleted the windowsUnixSocket branch November 25, 2024 08:05
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