Skip to content

WSL-Helper: make Linux vsock connection non-blocking. - #1374

Merged
ericpromislow merged 1 commit into
rancher-sandbox:mainfrom
mook-as:wsl-vsock-nonblocking
Jan 28, 2022
Merged

ericpromislow merged 1 commit into
rancher-sandbox:mainfrom
mook-as:wsl-vsock-nonblocking

Conversation

@mook-as

@mook-as mook-as commented Jan 28, 2022

Copy link
Copy Markdown
Contributor

When we pipe the connection between the unix docker socket (/var/run/docker.sock) and the vsock socket, we need to open the vsock side as non-blocking so that once the unix side is closed we can close the vsock side properly. Otherwise the client would not be able to detect the socket should close.

This copies an (Apache-2.0 licensed) file from github.com/linuxkit/virtsock so that we can make the resulting socket non-blocking. The only relevant change is in func (v *vsockListener) Accept() to add SOCK_NONBLOCK.

This should fix #1171.

When we pipe the connection between the unix docker socket
(/var/run/docker.sock) and the vsock socket, we need to open the vsock side
as non-blocking so that once the unix side is closed we can close the vsock
side properly.  Otherwise the client would not be able to detect the socket
should close.

This copies an (Apache-2.0 licensed) file from github.com/linuxkit/virtsock
so that we can make the resulting socket non-blocking.  The only relevant
change is in `func (v *vsockListener) Accept()` to add `SOCK_NONBLOCK`.

Signed-off-by: Mark Yen <[email protected]>
@mook-as
mook-as requested a review from mattfarina January 28, 2022 00:14

@ericpromislow ericpromislow left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This essentially calls unix.Accept4(v.fd, unix.SOCK_NONBLOCK) rather than unix.Accept(v.fd) and the prompt does return after a docker run -it ... ends. There's a slight delay before the prompt comes back, but I see that on macos without this change, so it's certainly normal.

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.

Executing an interactive terminal needs keystroke after exiting

4 participants