pub(crate) fn register(
        &mut self,
        socket: Socket,
        readable: bool,
        writable: bool,
    ) -> io::Result<()> {
        let previous = self.sockets.insert(socket, Registration {
            readable,
            writable,
            tick: self.tick,
        });

        let result = if previous.is_some() {
            poller_modify(&self.poller, socket, readable, writable)
        } else {
            poller_add(&self.poller, socket, readable, writable)
        };

        match result {
            Err(e) if is_bad_socket_error(&e) => {
                // We've been asked to monitor a socket, but the poller thinks
                // that the socket is invalid or closed. On occasion, curl will
                // give such sockets with the assumption that we will monitor
                // them until curl tells us to stop. With stateless pollers such
                // as `select(2)` this is not a problem, but most
                // high-performance stateless pollers need the socket to be
                // valid in order to monitor them.
                //
                // To get around this problem, we return `Ok` to the caller and
                // hold onto this currently invalid socket for later. Whenever
                // `poll` is called, we retry registering these sockets in the
                // hope that they will eventually become valid.
                tracing::debug!(socket, error = ?e, "bad socket registered, will try again later");
                self.bad_sockets.insert(socket);
                Ok(())
            }
            result => result,
        }
    }
/// Register a socket with the selector to begin receiving readiness events
/// for it.
///
/// This method can also be used to update/modify the readiness events you
/// are interested in for a previously registered socket.
Register a socket with the selector to begin receiving readiness events
for it.

This method can also be used to update/modify the readiness events you
are interested in for a previously registered socket.
Register a socket with the selector to begin receiving readiness events for it . This method can also be used to update / modify the readiness events you are interested in for a previously registered socket .
pub(crate) fn register(
        &mut self,
        socket: Socket,
        readable: bool,
        writable: bool,
    ) -> io::Result<()> {
        let previous = self.sockets.insert(socket, Registration {
            readable,
            writable,
            tick: self.tick,
        });
        let result = if previous.is_some() {
            poller_modify(&self.poller, socket, readable, writable)
        } else {
            poller_add(&self.poller, socket, readable, writable)
        };
        match result {
            Err(e) if is_bad_socket_error(&e) => {
                // We've been asked to monitor a socket, but the poller thinks
                // that the socket is invalid or closed. On occasion, curl will
                // give such sockets with the assumption that we will monitor
                // them until curl tells us to stop. With stateless pollers such
                // as `select(2)` this is not a problem, but most
                // high-performance stateless pollers need the socket to be
                // valid in order to monitor them.
                //
                // To get around this problem, we return `Ok` to the caller and
                // hold onto this currently invalid socket for later. Whenever
                // `poll` is called, we retry registering these sockets in the
                // hope that they will eventually become valid.
                tracing::debug!(socket, error = ?e, "bad socket registered, will try again later");
                self.bad_sockets.insert(socket);
                Ok(())
            }
            result => result,
        }
    }
pub ( crate ) fn register ( & mut self , socket : Socket , readable : bool , writable : bool , ) -> io :: Result < ( ) > { let previous = self . sockets . insert ( socket , Registration { readable , writable , tick : self . tick , } ) ; let result = if previous . is_some ( ) { poller_modify ( & self . poller , socket , readable , writable ) } else { poller_add ( & self . poller , socket , readable , writable ) } ; match result { Err ( e ) if is_bad_socket_error ( & e ) => { // We've been asked to monitor a socket, but the poller thinks // that the socket is invalid or closed. On occasion, curl will // give such sockets with the assumption that we will monitor // them until curl tells us to stop. With stateless pollers such // as `select(2)` this is not a problem, but most // high-performance stateless pollers need the socket to be // valid in order to monitor them. // // To get around this problem, we return `Ok` to the caller and // hold onto this currently invalid socket for later. Whenever // `poll` is called, we retry registering these sockets in the // hope that they will eventually become valid. tracing :: debug ! ( socket error e " " ) ; self . bad_sockets . insert ( socket ) ; Ok ( ( ) ) } result => result , } }
Register a socket with the selector to begin receiving readiness events
for it.
Register a socket with the selector to begin receiving readiness events for it .
&mut self
socket
Socket
readable
bool
writable
bool