Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bbc4ee2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix lints from Rust 1.60"

parents e48f6692 4156cea1
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ impl Cache {
    /// Behaves as `Config::from_cert_path`, but with a cache.
    /// If any object previously given out by this cache is still live,
    /// a duplicate will not be made.
    pub fn from_key(&self, key: &Key) -> Result<Config> {
    pub fn get(&self, key: &Key) -> Result<Config> {
        // Fast path - read-only access to state retrieves config
        if let Some(config) = self.state.read().unwrap().get_config(key) {
            return Ok(config);
@@ -191,9 +191,9 @@ fn create_quiche_config() {
fn shared_cache() {
    let cache_a = Cache::new();
    let cache_b = cache_a.clone();
    let config_a = cache_a.from_key(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    let config_a = cache_a.get(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    assert_eq!(Arc::strong_count(&config_a.0), 2);
    let _config_b = cache_b.from_key(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    let _config_b = cache_b.get(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    assert_eq!(Arc::strong_count(&config_a.0), 3);
}

@@ -203,11 +203,11 @@ fn different_keys() {
    let key_a = Key { cert_path: None, max_idle_timeout: 1000 };
    let key_b = Key { cert_path: Some("a".to_string()), max_idle_timeout: 1000 };
    let key_c = Key { cert_path: Some("a".to_string()), max_idle_timeout: 5000 };
    let config_a = cache.from_key(&key_a).unwrap();
    let config_b = cache.from_key(&key_b).unwrap();
    let _config_b = cache.from_key(&key_b).unwrap();
    let config_c = cache.from_key(&key_c).unwrap();
    let _config_c = cache.from_key(&key_c).unwrap();
    let config_a = cache.get(&key_a).unwrap();
    let config_b = cache.get(&key_b).unwrap();
    let _config_b = cache.get(&key_b).unwrap();
    let config_c = cache.get(&key_c).unwrap();
    let _config_c = cache.get(&key_c).unwrap();

    assert_eq!(Arc::strong_count(&config_a.0), 1);
    assert_eq!(Arc::strong_count(&config_b.0), 2);
@@ -222,9 +222,9 @@ fn lifetimes() {
    let cache = Cache::new();
    let key_a = Key { cert_path: Some("a".to_string()), max_idle_timeout: 1000 };
    let key_b = Key { cert_path: Some("b".to_string()), max_idle_timeout: 1000 };
    let config_none = cache.from_key(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    let config_a = cache.from_key(&key_a).unwrap();
    let config_b = cache.from_key(&key_b).unwrap();
    let config_none = cache.get(&Key { cert_path: None, max_idle_timeout: 1000 }).unwrap();
    let config_a = cache.get(&key_a).unwrap();
    let config_b = cache.get(&key_b).unwrap();

    // The first two we created should have a strong count of one - those handles are the only
    // thing keeping them alive.
@@ -232,7 +232,7 @@ fn lifetimes() {
    assert_eq!(Arc::strong_count(&config_a.0), 1);

    // If we try to get another handle we already have, it should be the same one.
    let _config_a2 = cache.from_key(&key_a).unwrap();
    let _config_a2 = cache.get(&key_a).unwrap();
    assert_eq!(Arc::strong_count(&config_a.0), 2);

    // config_b was most recently created, so it should have a keep-alive
@@ -256,7 +256,7 @@ fn lifetimes() {

    // If we try to get a config which is still kept alive by the cache, we should get the same
    // one.
    let _config_b2 = cache.from_key(&key_b).unwrap();
    let _config_b2 = cache.get(&key_b).unwrap();
    assert_eq!(config_b_weak.strong_count(), 2);

    // We broke None, but "a" and "b" should still both be alive. Check that
+6 −9
Original line number Diff line number Diff line
@@ -264,15 +264,12 @@ impl H3Driver {
    async fn drive(mut self) -> Result<Driver> {
        let _ = self.driver.status_tx.send(Status::H3);
        loop {
            match self.drive_once().await {
                Err(e) => {
            if let Err(e) = self.drive_once().await {
                let _ = self
                    .driver
                    .status_tx
                    .send(Status::Dead { session: self.driver.quiche_conn.session() });
                    return Err(e);
                }
                Ok(()) => (),
                return Err(e)
            }
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ impl Driver {
                    cert_path: info.cert_path.clone(),
                    max_idle_timeout: info.idle_timeout_ms,
                };
                let config = self.config_cache.from_key(&key)?;
                let config = self.config_cache.get(&key)?;
                vacant.insert(
                    Network::new(info, config, self.validation.clone(), self.tagger.clone())
                        .await?,
+1 −4
Original line number Diff line number Diff line
@@ -87,10 +87,7 @@ impl Dispatcher {
            .build()?;
        let join_handle = runtime.spawn(async {
            let result = Driver::new(cmd_receiver, validation, tagger).drive().await;
            match result {
                Err(ref e) => error!("Dispatcher driver exited due to {:?}", e),
                Ok(()) => (),
            }
            if let Err(ref e) = result { error!("Dispatcher driver exited due to {:?}", e) }
            result
        });
        Ok(Dispatcher { cmd_sender, join_handle, runtime })
+4 −8
Original line number Diff line number Diff line
@@ -113,14 +113,10 @@ impl Driver {
    pub async fn drive(mut self) -> Result<()> {
        while let Some(cmd) = self.command_rx.recv().await {
            match cmd {
                Command::Probe(duration) => match self.probe(duration).await {
                    Err(e) => self.status_tx.send(Status::Failed(Arc::new(e)))?,
                    Ok(()) => (),
                },
                Command::Query(query) => match self.send_query(query).await {
                    Err(e) => debug!("Unable to send query: {:?}", e),
                    Ok(()) => (),
                },
                Command::Probe(duration) =>
                    if let Err(e) = self.probe(duration).await { self.status_tx.send(Status::Failed(Arc::new(e)))? },
                Command::Query(query) =>
                    if let Err(e) = self.send_query(query).await { debug!("Unable to send query: {:?}", e) },
            };
        }
        Ok(())