Jens-G opened a new pull request, #3931:
URL: https://github.com/apache/thrift/pull/3931

   `TServer::listen` handed each accepted connection to `handle_stream` with 
`?`, so an error while setting up one connection ended the listen loop, and 
`listen()` returned. `TTcpChannel::split()` fails when the stream cannot be 
duplicated, for example while the process has no file descriptors left. 
`listen_uds` has the same loop, and there `split()` called 
`try_clone().unwrap()` and panicked instead.
   
   This change:
   
   - adds `accept_stream()`, which logs a connection that cannot be set up, 
drops it and lets the loop go on accepting, as it already does after a failed 
`accept`. `listen`, `listen_tls` and `listen_uds` all use it. `listen_tls` 
could not fail at that point, because the `split()` of `TTlsServerChannel` only 
clones an `Arc`; it is changed so that the three loops stay alike.
   - returns the `try_clone()` error from `UnixStream::split()` instead of 
panicking.
   
   Not part of this change: while no descriptors are left, `accept` keeps 
failing and the loop retries at once. A short back-off there would be a 
separate change.
   
   ### How it was checked
   
   - A new unit test in `lib/rs/src/server/threaded.rs` hands the server a 
channel whose `split()` fails and then a working one; the second must reach the 
processor.
   - Under `ulimit -n 41` with Rust 1.85.1: on master, `listen` returns 
`Err("cannot clone underlying tcp stream")` and the process exits; with this 
change it keeps serving once descriptors are free again.
   - `cargo fmt --check`, both clippy runs, `cargo check --features rustls` and 
`cargo test` (185 of 185) pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to