fn run(mut self) -> Result<(), Error> {
        let mut wait_fds = [self.notify_rx.as_wait_fd()];
        wait_fds[0].poll_on_read(true);

        debug!("agent ready");

        // Agent main loop.
        loop {
            self.poll_messages()?;

            // Perform any pending reads or writes and handle any state changes.
            self.dispatch()?;

            if self.close_requested {
                break;
            }

            // Determine the blocking timeout value. If curl returns None, then it is unsure as to what timeout value is
            // appropriate. In this case we use a default value.
            let mut timeout = self.multi.get_timeout()?.unwrap_or(DEFAULT_TIMEOUT);

            // HACK: A mysterious bug in recent versions of curl causes it to return the value of
            // `CURLOPT_CONNECTTIMEOUT_MS` a few times during the DNS resolve phase. Work around this issue by
            // truncating this known value to 1ms to avoid blocking the agent loop for a long time.
            // See https://github.com/curl/curl/issues/2996 and https://github.com/alexcrichton/curl-rust/issues/227.
            if timeout == Duration::from_secs(300) {
                debug!("HACK: curl returned CONNECTTIMEOUT of {:?}, truncating to 1ms!", timeout);
                timeout = Duration::from_millis(1);
            }

            // Truncate the timeout to the max value.
            timeout = timeout.min(MAX_TIMEOUT);

            // Block until activity is detected or the timeout passes.
            if timeout > Duration::from_secs(0) {
                trace!("polling with timeout of {:?}", timeout);
                self.multi.wait(&mut wait_fds, timeout)?;
            }

            // We might have woken up early from the notify fd, so drain its queue.
            if self.notify_rx.drain() {
                trace!("woke up from notify fd");
            }
        }

        debug!("agent shutting down");

        self.requests.clear();
        self.multi.close()?;

        Ok(())
    }
/// Run the agent in the current thread until requested to stop.
Run the agent in the current thread until requested to stop.
Run the agent in the current thread until requested to stop .
fn run(mut self) -> Result<(), Error> {
        let mut wait_fds = [self.notify_rx.as_wait_fd()];
        wait_fds[0].poll_on_read(true);
        debug!("agent ready");
        // Agent main loop.
        loop {
            self.poll_messages()?;
            // Perform any pending reads or writes and handle any state changes.
            self.dispatch()?;
            if self.close_requested {
                break;
            }
            // Determine the blocking timeout value. If curl returns None, then it is unsure as to what timeout value is
            // appropriate. In this case we use a default value.
            let mut timeout = self.multi.get_timeout()?.unwrap_or(DEFAULT_TIMEOUT);
            // HACK: A mysterious bug in recent versions of curl causes it to return the value of
            // `CURLOPT_CONNECTTIMEOUT_MS` a few times during the DNS resolve phase. Work around this issue by
            // truncating this known value to 1ms to avoid blocking the agent loop for a long time.
            // See https://github.com/curl/curl/issues/2996 and https://github.com/alexcrichton/curl-rust/issues/227.
            if timeout == Duration::from_secs(300) {
                debug!("HACK: curl returned CONNECTTIMEOUT of {:?}, truncating to 1ms!", timeout);
                timeout = Duration::from_millis(1);
            }
            // Truncate the timeout to the max value.
            timeout = timeout.min(MAX_TIMEOUT);
            // Block until activity is detected or the timeout passes.
            if timeout > Duration::from_secs(0) {
                trace!("polling with timeout of {:?}", timeout);
                self.multi.wait(&mut wait_fds, timeout)?;
            }
            // We might have woken up early from the notify fd, so drain its queue.
            if self.notify_rx.drain() {
                trace!("woke up from notify fd");
            }
        }
        debug!("agent shutting down");
        self.requests.clear();
        self.multi.close()?;
        Ok(())
    }
fn run ( mut self ) -> Result < ( ) , Error > { let mut wait_fds = [ self . notify_rx . as_wait_fd ( ) ] ; wait_fds [ 0 ] . poll_on_read ( true ) ; debug ! ( " " ) ; // Agent main loop. loop { self . poll_messages ( ) ? ; // Perform any pending reads or writes and handle any state changes. self . dispatch ( ) ? ; if self . close_requested { break ; } // Determine the blocking timeout value. If curl returns None, then it is unsure as to what timeout value is // appropriate. In this case we use a default value. let mut timeout = self . multi . get_timeout ( ) ? . unwrap_or ( DEFAULT_TIMEOUT ) ; // HACK: A mysterious bug in recent versions of curl causes it to return the value of // `CURLOPT_CONNECTTIMEOUT_MS` a few times during the DNS resolve phase. Work around this issue by // truncating this known value to 1ms to avoid blocking the agent loop for a long time. // See https://github.com/curl/curl/issues/2996 and https://github.com/alexcrichton/curl-rust/issues/227. if timeout == Duration :: from_secs ( 300 ) { debug ! ( " " timeout ) ; timeout = Duration :: from_millis ( 1 ) ; } // Truncate the timeout to the max value. timeout = timeout . min ( MAX_TIMEOUT ) ; // Block until activity is detected or the timeout passes. if timeout > Duration :: from_secs ( 0 ) { trace ! ( " " timeout ) ; self . multi . wait ( & mut wait_fds , timeout ) ? ; } // We might have woken up early from the notify fd, so drain its queue. if self . notify_rx . drain ( ) { trace ! ( " " ) ; } } debug ! ( " " ) ; self . requests . clear ( ) ; self . multi . close ( ) ? ; Ok ( ( ) ) }
Run the agent in the current thread until requested to stop.
Run the agent in the current thread until requested to stop .
mut self
mut self