containerd / ttrpc-rust

Rust implementation of ttrpc (GRPC for low-memory environments)
Apache License 2.0
197 stars 47 forks source link

Once an accept fails, the server will exit #239

Closed quanweiZhou closed 1 month ago

quanweiZhou commented 1 month ago

Description of problem

The current process will exit the loop if Accept fails once, causing all subsequent links to fail to accept. https://github.com/containerd/ttrpc-rust/blob/v0.5.7/src/sync/server.rs#L426

        let handler = thread::Builder::new()
            .name("listener_loop".into())
            .spawn(move || {
                ...

                loop {
                    ...

                    #[cfg(target_os = "linux")]
                    let fd = match accept4(listener, SockFlag::SOCK_CLOEXEC) {
                        Ok(fd) => fd,
                        Err(e) => {
                            error!("failed to accept error {:?}", e);
                            break;
                        }
                    };

                    ...
            })
            .unwrap();

Expected result

If the Accept error occurs, an error can be output to ensure that the subsequent connect can be accepted normally.

Actual result

If the Accept error is detected, the loop will be exited, causing subsequent requests to fail to be accepted.