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

Call to a potentially blocking function in aio::connect_simple #591

Closed
thalesfragoso opened this issue Mar 17, 2022 · 2 comments
Closed

Comments

@thalesfragoso
Copy link

connect_simple (which is async) calls get_socket_addrs:
https://github.com/mitsuhiko/redis-rs/blob/b8eb47303c5728e943b914cd10dc35d1fceee05c/src/aio.rs#L459

Which will end up calling the libstd implementation of ToSocketAddrs for str, this will block if the str is a hostname:
https://github.com/mitsuhiko/redis-rs/blob/b8eb47303c5728e943b914cd10dc35d1fceee05c/src/aio.rs#L496

The usual way to solve this is to wrap the call to to_socket_addrs in a "spawn_blocking", both tokio and async-std have utility functions for that. I guess we could either add spawn_blocking to the RedisRuntime trait, or a more specific method, like get_socket_addrs or lookup_host. I think I would prefer the most general spawn_blocking, since it can be useful for other stuff.

I can provide a PR once there's a minimal consensus on the proper solution.

@tasn
Copy link

tasn commented May 10, 2022

Related to #379

@doyshinda
Copy link
Contributor

This was fixed in #606

@djc djc closed this as completed May 26, 2022
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

No branches or pull requests

4 participants