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

UnixStream is blocking #209

Closed
Mygod opened this issue Mar 15, 2020 · 12 comments
Closed

UnixStream is blocking #209

Mygod opened this issue Mar 15, 2020 · 12 comments

Comments

@Mygod
Copy link
Contributor

Mygod commented Mar 15, 2020

Please use the one in tokio or async-std. While it seems like they implemented it using polling instead of signals (<aio.h>), it is better than blocking operations.

@Mygod
Copy link
Contributor Author

Mygod commented Mar 15, 2020

Okay it seems like both of these two use mio, which uses <sys/select.h> underthehood, so I guess that is fine too.

@zonyitoo
Copy link
Collaborator

Which UnixStream? The one in src/relay/sys/unix/mod.rs:protect?

@Mygod
Copy link
Contributor Author

Mygod commented Mar 15, 2020

I saw you are using tokio::net::UnixStream for stat_path... This is the correct one.

@zonyitoo
Copy link
Collaborator

Yup. @madeye said protect doesn't need to be nonblocked.

@Mygod
Copy link
Contributor Author

Mygod commented Mar 15, 2020

While protect is basically a series of RPCs, why not just use nonblocking variant everywhere?

@zonyitoo
Copy link
Collaborator

It's true. I am going to add it for you. @madeye

@madeye
Copy link
Contributor

madeye commented Mar 15, 2020

Awesome 👍

@zonyitoo
Copy link
Collaborator

zonyitoo commented Mar 15, 2020

BIG PROBLEM: sendfd crate doesn't support async i/o.

Possible solutions:

  1. Create a PR for tokio to support transferring FDs Support transferring FDs between processes for UnixStream and UnixDatagram tokio-rs/tokio#2322
  2. Making a customized UnixStream all by myself.

zonyitoo added a commit that referenced this issue Mar 15, 2020
@zonyitoo
Copy link
Collaborator

zonyitoo commented Mar 15, 2020

I chose 2. :P
Please @madeye help to test it for me, because I don't have any Android devices available.

@madeye
Copy link
Contributor

madeye commented Mar 15, 2020

Sure.

@Mygod
Copy link
Contributor Author

Mygod commented Mar 15, 2020

I see. Technically SendWithFd is implemented by sendfd and not supported by stdlib. 6373040 seems like a good solution. 👍

@madeye
Copy link
Contributor

madeye commented Mar 16, 2020

6373040 works well. I think we can close this now.

@Mygod Mygod closed this as completed Mar 16, 2020
madeye pushed a commit to Mygod/shadowsocks-rust that referenced this issue Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants