fn handle_event(&mut self, fd: RawFd, evset: EventSet) {
        debug!(
            "vsock: muxer processing event: fd={}, evset={:?}",
            fd, evset
        );

        match self.listener_map.get_mut(&fd) {
            // This event needs to be forwarded to a `MuxerConnection` that is listening for
            // it.
            Some(EpollListener::Connection { key, evset }) => {
                let key_copy = *key;
                let evset_copy = *evset;
                // The handling of this event will most probably mutate the state of the
                // receiving conection. We'll need to check for new pending RX, event set
                // mutation, and all that, so we're wrapping the event delivery inside those
                // checks.
                self.apply_conn_mutation(key_copy, |conn| {
                    conn.notify(evset_copy);
                });
            }

            Some(EpollListener::WrapTcp { port, listener }) => {
                let peer_port = *port;

                debug!("WrapTcp: peer_port {}", peer_port);

                listener
                    .accept()
                    .map_err(Error::UnixAccept)
                    .and_then(|(stream, _)| {
                        stream
                            .set_nonblocking(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        stream
                            .set_nodelay(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        let local_port = self.allocate_local_port();
                        self.add_connection(
                            ConnMapKey {
                                local_port,
                                peer_port,
                            },
                            MuxerConnection::new_local_wrap_init(
                                Box::new(stream) as Box<dyn CommonStream>,
                                uapi::VSOCK_HOST_CID,
                                self.cid,
                                local_port,
                                peer_port,
                            ),
                        )
                    })
                    .unwrap_or_else(|err| {
                        warn!("vsock: unable to accept wrapped TCP connection: {:?}", err);
                    });
            }

            Some(EpollListener::WrapUnix { port, listener }) => {
                let peer_port = *port;

                listener
                    .accept()
                    .map_err(Error::UnixAccept)
                    .and_then(|(stream, _)| {
                        stream
                            .set_nonblocking(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        let local_port = self.allocate_local_port();
                        self.add_connection(
                            ConnMapKey {
                                local_port,
                                peer_port,
                            },
                            MuxerConnection::new_local_wrap_init(
                                Box::new(stream) as Box<dyn CommonStream>,
                                uapi::VSOCK_HOST_CID,
                                self.cid,
                                local_port,
                                peer_port,
                            ),
                        )
                    })
                    .unwrap_or_else(|err| {
                        warn!("vsock: unable to accept wrapped unix connection: {:?}", err);
                    });
            }
            _ => {
                info!("vsock: unexpected event: fd={:?}, evset={:?}", fd, evset);
            }
        }
    }
/// Handle/dispatch an epoll event to its listener.
Handle/dispatch an epoll event to its listener.
Handle / dispatch an epoll event to its listener .
fn handle_event(&mut self, fd: RawFd, evset: EventSet) {
        debug!(
            "vsock: muxer processing event: fd={}, evset={:?}",
            fd, evset
        );
        match self.listener_map.get_mut(&fd) {
            // This event needs to be forwarded to a `MuxerConnection` that is listening for
            // it.
            Some(EpollListener::Connection { key, evset }) => {
                let key_copy = *key;
                let evset_copy = *evset;
                // The handling of this event will most probably mutate the state of the
                // receiving conection. We'll need to check for new pending RX, event set
                // mutation, and all that, so we're wrapping the event delivery inside those
                // checks.
                self.apply_conn_mutation(key_copy, |conn| {
                    conn.notify(evset_copy);
                });
            }
            Some(EpollListener::WrapTcp { port, listener }) => {
                let peer_port = *port;
                debug!("WrapTcp: peer_port {}", peer_port);
                listener
                    .accept()
                    .map_err(Error::UnixAccept)
                    .and_then(|(stream, _)| {
                        stream
                            .set_nonblocking(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        stream
                            .set_nodelay(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        let local_port = self.allocate_local_port();
                        self.add_connection(
                            ConnMapKey {
                                local_port,
                                peer_port,
                            },
                            MuxerConnection::new_local_wrap_init(
                                Box::new(stream) as Box<dyn CommonStream>,
                                uapi::VSOCK_HOST_CID,
                                self.cid,
                                local_port,
                                peer_port,
                            ),
                        )
                    })
                    .unwrap_or_else(|err| {
                        warn!("vsock: unable to accept wrapped TCP connection: {:?}", err);
                    });
            }
            Some(EpollListener::WrapUnix { port, listener }) => {
                let peer_port = *port;
                listener
                    .accept()
                    .map_err(Error::UnixAccept)
                    .and_then(|(stream, _)| {
                        stream
                            .set_nonblocking(true)
                            .map(|_| stream)
                            .map_err(Error::WrapUnixAccept)
                    })
                    .and_then(|stream| {
                        let local_port = self.allocate_local_port();
                        self.add_connection(
                            ConnMapKey {
                                local_port,
                                peer_port,
                            },
                            MuxerConnection::new_local_wrap_init(
                                Box::new(stream) as Box<dyn CommonStream>,
                                uapi::VSOCK_HOST_CID,
                                self.cid,
                                local_port,
                                peer_port,
                            ),
                        )
                    })
                    .unwrap_or_else(|err| {
                        warn!("vsock: unable to accept wrapped unix connection: {:?}", err);
                    });
            }
            _ => {
                info!("vsock: unexpected event: fd={:?}, evset={:?}", fd, evset);
            }
        }
    }
fn handle_event ( & mut self , fd : RawFd , evset : EventSet ) { debug ! ( " " fd evset ) ; match self . listener_map . get_mut ( & fd ) { // This event needs to be forwarded to a `MuxerConnection` that is listening for // it. Some ( EpollListener :: Connection { key , evset } ) => { let key_copy = * key ; let evset_copy = * evset ; // The handling of this event will most probably mutate the state of the // receiving conection. We'll need to check for new pending RX, event set // mutation, and all that, so we're wrapping the event delivery inside those // checks. self . apply_conn_mutation ( key_copy , | conn | { conn . notify ( evset_copy ) ; } ) ; } Some ( EpollListener :: WrapTcp { port , listener } ) => { let peer_port = * port ; debug ! ( " " peer_port ) ; listener . accept ( ) . map_err ( Error :: UnixAccept ) . and_then ( | ( stream , _ ) | { stream . set_nonblocking ( true ) . map ( | _ | stream ) . map_err ( Error :: WrapUnixAccept ) } ) . and_then ( | stream | { stream . set_nodelay ( true ) . map ( | _ | stream ) . map_err ( Error :: WrapUnixAccept ) } ) . and_then ( | stream | { let local_port = self . allocate_local_port ( ) ; self . add_connection ( ConnMapKey { local_port , peer_port , } , MuxerConnection :: new_local_wrap_init ( Box :: new ( stream ) as Box < dyn CommonStream > , uapi :: VSOCK_HOST_CID , self . cid , local_port , peer_port , ) , ) } ) . unwrap_or_else ( | err | { warn ! ( " " err ) ; } ) ; } Some ( EpollListener :: WrapUnix { port , listener } ) => { let peer_port = * port ; listener . accept ( ) . map_err ( Error :: UnixAccept ) . and_then ( | ( stream , _ ) | { stream . set_nonblocking ( true ) . map ( | _ | stream ) . map_err ( Error :: WrapUnixAccept ) } ) . and_then ( | stream | { let local_port = self . allocate_local_port ( ) ; self . add_connection ( ConnMapKey { local_port , peer_port , } , MuxerConnection :: new_local_wrap_init ( Box :: new ( stream ) as Box < dyn CommonStream > , uapi :: VSOCK_HOST_CID , self . cid , local_port , peer_port , ) , ) } ) . unwrap_or_else ( | err | { warn ! ( " " err ) ; } ) ; } _ => { info ! ( " " fd evset ) ; } } }
Handle/dispatch an epoll event to its listener.
Handle / dispatch an epoll event to its listener .
&mut self
fd
RawFd
evset
EventSet