fn add_connection(&mut self, key: ConnMapKey, conn: MuxerConnection) -> Result<()> {
        // We might need to make room for this new connection, so let's sweep the kill queue
        // first.  It's fine to do this here because:
        // - unless the kill queue is out of sync, this is a pretty inexpensive operation; and
        // - we are under no pressure to respect any accurate timing for connection
        //   termination.
        self.sweep_killq();

        if self.conn_map.len() >= defs::MAX_CONNECTIONS {
            info!(
                "vsock: muxer connection limit reached ({})",
                defs::MAX_CONNECTIONS
            );
            return Err(Error::TooManyConnections);
        }

        self.add_listener(
            conn.as_raw_fd(),
            EpollListener::Connection {
                key,
                evset: conn.get_polled_evset(),
            },
        )
        .map(|_| {
            if conn.has_pending_rx() {
                // We can safely ignore any error in adding a connection RX indication. Worst
                // case scenario, the RX queue will get desynchronized, but we'll handle that
                // the next time we need to yield an RX packet.
                self.rxq.push(MuxerRx::ConnRx(key));
            }
            self.conn_map.insert(key, conn);
            METRICS.vsock.conns_added.inc();
        })
    }
/// Add a new connection to the active connection pool.
Add a new connection to the active connection pool.
Add a new connection to the active connection pool .
fn add_connection(&mut self, key: ConnMapKey, conn: MuxerConnection) -> Result<()> {
        // We might need to make room for this new connection, so let's sweep the kill queue
        // first.  It's fine to do this here because:
        // - unless the kill queue is out of sync, this is a pretty inexpensive operation; and
        // - we are under no pressure to respect any accurate timing for connection
        //   termination.
        self.sweep_killq();
        if self.conn_map.len() >= defs::MAX_CONNECTIONS {
            info!(
                "vsock: muxer connection limit reached ({})",
                defs::MAX_CONNECTIONS
            );
            return Err(Error::TooManyConnections);
        }
        self.add_listener(
            conn.as_raw_fd(),
            EpollListener::Connection {
                key,
                evset: conn.get_polled_evset(),
            },
        )
        .map(|_| {
            if conn.has_pending_rx() {
                // We can safely ignore any error in adding a connection RX indication. Worst
                // case scenario, the RX queue will get desynchronized, but we'll handle that
                // the next time we need to yield an RX packet.
                self.rxq.push(MuxerRx::ConnRx(key));
            }
            self.conn_map.insert(key, conn);
            METRICS.vsock.conns_added.inc();
        })
    }
fn add_connection ( & mut self , key : ConnMapKey , conn : MuxerConnection ) -> Result < ( ) > { // We might need to make room for this new connection, so let's sweep the kill queue // first.  It's fine to do this here because: // - unless the kill queue is out of sync, this is a pretty inexpensive operation; and // - we are under no pressure to respect any accurate timing for connection //   termination. self . sweep_killq ( ) ; if self . conn_map . len ( ) >= defs :: MAX_CONNECTIONS { info ! ( " " defs MAX_CONNECTIONS ) ; return Err ( Error :: TooManyConnections ) ; } self . add_listener ( conn . as_raw_fd ( ) , EpollListener :: Connection { key , evset : conn . get_polled_evset ( ) , } , ) . map ( | _ | { if conn . has_pending_rx ( ) { // We can safely ignore any error in adding a connection RX indication. Worst // case scenario, the RX queue will get desynchronized, but we'll handle that // the next time we need to yield an RX packet. self . rxq . push ( MuxerRx :: ConnRx ( key ) ) ; } self . conn_map . insert ( key , conn ) ; METRICS . vsock . conns_added . inc ( ) ; } ) }
Add a new connection to the active connection pool.
Add a new connection to the active connection pool .
&mut self
key
ConnMapKey
conn
MuxerConnection
&mut self
key
ConnMapKey
conn
MuxerConnection