Repository: tokio-rs/axum
File: axum/src/serve.rs (Rust)

Code before:
                mut make_service,
                _marker: _,
            } = self;

            loop {
                let (tcp_stream, remote_addr) = match tcp_listener.accept().await {
                    Ok(conn) => conn,
                    Err(e) => {
                        // Connection errors can be ignored directly, continue
                        // by accepting the next request.
                        if is_connection_error(&e) {
                            continue;
                        }

                        // [From `hyper::Server` in 0.14](https://github.com/hyperium/hyper/blob/v0.14.27/src/server/tcp.rs#L186)
                        //
                        // > A possible scenario is that the process has hit the max open files
                        // > allowed, and so trying to accept a new connection will fail with
                        // > `EMFILE`. In some cases, it's preferable to just wait for some time, if
                        // > the application will likely close some files (or connections), and try
                        // > to accept the connection again. If this option is `true`, the error
                        // > will be logged at the `error` level, since it is still a big deal,
                        // > and then the listener will sleep for 1 second.
                        //
                        // hyper allowed customizing this but axum does not.
                        error!("accept error: {}", e);
                        tokio::time::sleep(Duration::from_secs(1)).await;
                        continue;
                    }
                };
                let tcp_stream = TokioIo::new(tcp_stream);

                poll_fn(|cx| make_service.poll_ready(cx))
                    .await
                    .unwrap_or_else(|err| match err {});

                let tower_service = make_service
                    .call(IncomingStream {
                        tcp_stream: &tcp_stream,
                        remote_addr,
                    })
                    .await
                    .unwrap_or_else(|err| match err {});

                let hyper_service = TowerToHyperService {
                    service: tower_service,
                };

                tokio::task::spawn(async move {
                    match Builder::new(TokioExecutor::new())
                        // upgrades needed for websockets

Review comment (suggestion):
```suggestion
                        error!("accept error: {e}");
```

Code after:
                mut make_service,
                _marker: _,
            } = self;

            loop {
                let (tcp_stream, remote_addr) = match tcp_listener.accept().await {
                    Ok(conn) => conn,
                    Err(e) => {
                        // Connection errors can be ignored directly, continue
                        // by accepting the next request.
                        if is_connection_error(&e) {
                            continue;
                        }

                        // [From `hyper::Server` in 0.14](https://github.com/hyperium/hyper/blob/v0.14.27/src/server/tcp.rs#L186)
                        //
                        // > A possible scenario is that the process has hit the max open files
                        // > allowed, and so trying to accept a new connection will fail with
                        // > `EMFILE`. In some cases, it's preferable to just wait for some time, if
                        // > the application will likely close some files (or connections), and try
                        // > to accept the connection again. If this option is `true`, the error
                        // > will be logged at the `error` level, since it is still a big deal,
                        // > and then the listener will sleep for 1 second.
                        //
                        // hyper allowed customizing this but axum does not.
                        error!("accept error: {e}");
                        tokio::time::sleep(Duration::from_secs(1)).await;
                        continue;
                    }
                };
                let tcp_stream = TokioIo::new(tcp_stream);

                poll_fn(|cx| make_service.poll_ready(cx))
                    .await
                    .unwrap_or_else(|err| match err {});

                let tower_service = make_service
                    .call(IncomingStream {
                        tcp_stream: &tcp_stream,
                        remote_addr,
                    })
                    .await
                    .unwrap_or_else(|err| match err {});

                let hyper_service = TowerToHyperService {
                    service: tower_service,
                };

                tokio::task::spawn(async move {
                    match Builder::new(TokioExecutor::new())
                        // upgrades needed for websockets