serve_with_incoming_shutdown doesn't work properly when TcpListener::from_std is used
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
### Version
v0.9.2, 0d86e360ab45779770ca150c8487fe7940c299a9
### Platform
macOS 13.4.1(22F82)
Darwin (hostname) 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64
### Description
Using `TcpListener::from_std` prevents `tonic::transport::server::serve_with_incoming_shutdown` from working properly.
Full code(based on examples/src/streaming/server.rs): https://pastebin.com/4CPZ0QZs
Code snippet:
```rust
Server::builder()
...
.serve_with_incoming_shutdown(TcpListenerStream::new(TcpListener::from_std(listener)?), (async ctrl_c handler))
```
This code works properly when there's no client connection. (i.e. the server shuts down when I press ctrl_c)
However, after a client tries to connect, the async signal handler doesn't get the executor, preventing the server from shutting down when I press ctrl_c.
Replacing the std TcpListener with tokio version, or changing the async ctrl_c into busy wait solves the issue.
I'm opening this because I'm not sure if it's intended(i.e. I'm supposed to not use std TcpListener) or not.
Contributor guide
Assessment
This issue has not been assessed yet.