pub async fn start(&mut self) -> Result<()> {
        info!("accepting inbound connections");

        loop {
            // Wait for a permit to become available
            //
            // `acquire()` returns `Err` when the semaphore has been closed. We don't ever
            // close the semaphore, so `unwrap()` is safe.
            self.limit_connections.acquire().await.unwrap().forget();

            // Accept a new socket. This will attempt to perform error handling. The `accept`
            // method internally attempts to recover errors, so an error here is non-recoverable.
            let socket = self.accept().await?;
            debug!("accepted connection from {}", socket.peer_addr().unwrap());

            // Create the necessary per-connection handler state. The handler needs a handle to
            // the max connections semaphore. When the handler is done processing the connection,
            // a permit is added back to the semaphore.
            let mut handler =
                Handler::new(socket, self.store.clone(), self.limit_connections.clone());

            // Spawn a new task to process the connections
            tokio::spawn(async move {
                // Process the connection. If an error is encountered, log it.
                if let Err(err) = handler.run().await {
                    error!("{}", err);
                }
            });
        }
    }
/// Start listening for inbound connections. For each inbound connection, spawn a
/// task to process that connection.
///
/// Returns `Err` if accepting returns an error.
Start listening for inbound connections. For each inbound connection, spawn a
task to process that connection.

Returns `Err` if accepting returns an error.
Start listening for inbound connections . For each inbound connection spawn a task to process that connection . Returns ` Err ` if accepting returns an error .
pub async fn start(&mut self) -> Result<()> {
        info!("accepting inbound connections");
        loop {
            // Wait for a permit to become available
            //
            // `acquire()` returns `Err` when the semaphore has been closed. We don't ever
            // close the semaphore, so `unwrap()` is safe.
            self.limit_connections.acquire().await.unwrap().forget();
            // Accept a new socket. This will attempt to perform error handling. The `accept`
            // method internally attempts to recover errors, so an error here is non-recoverable.
            let socket = self.accept().await?;
            debug!("accepted connection from {}", socket.peer_addr().unwrap());
            // Create the necessary per-connection handler state. The handler needs a handle to
            // the max connections semaphore. When the handler is done processing the connection,
            // a permit is added back to the semaphore.
            let mut handler =
                Handler::new(socket, self.store.clone(), self.limit_connections.clone());
            // Spawn a new task to process the connections
            tokio::spawn(async move {
                // Process the connection. If an error is encountered, log it.
                if let Err(err) = handler.run().await {
                    error!("{}", err);
                }
            });
        }
    }
pub async fn start ( & mut self ) -> Result < ( ) > { info ! ( " " ) ; loop { // Wait for a permit to become available // // `acquire()` returns `Err` when the semaphore has been closed. We don't ever // close the semaphore, so `unwrap()` is safe. self . limit_connections . acquire ( ) . await . unwrap ( ) . forget ( ) ; // Accept a new socket. This will attempt to perform error handling. The `accept` // method internally attempts to recover errors, so an error here is non-recoverable. let socket = self . accept ( ) . await ? ; debug ! ( " " socket peer_addr ( ) unwrap ( ) ) ; // Create the necessary per-connection handler state. The handler needs a handle to // the max connections semaphore. When the handler is done processing the connection, // a permit is added back to the semaphore. let mut handler = Handler :: new ( socket , self . store . clone ( ) , self . limit_connections . clone ( ) ) ; // Spawn a new task to process the connections tokio :: spawn ( async move { // Process the connection. If an error is encountered, log it. if let Err ( err ) = handler . run ( ) . await { error ! ( " " err ) ; } } ) ; } }
Start listening for inbound connections.
Start listening for inbound connections .
&mut self
&mut self