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

Commit 0950c3f3 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

DoH: Change Network to use try_send am: 5d2a1071 am: d11879c3

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1906166

Change-Id: I1d7ca8d78db3abc1a55bce35313e348627bd2353
parents 201af352 d11879c3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ impl Network {
                .unwrap_or_else(|_| {
                .unwrap_or_else(|_| {
                    warn!("Query result listener went away before receiving a response")
                    warn!("Query result listener went away before receiving a response")
                }),
                }),
            Status::Live => self.command_tx.send(Command::Query(query)).await?,
            Status::Live => self.command_tx.try_send(Command::Query(query))?,
        }
        }
        Ok(())
        Ok(())
    }
    }
+2 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,8 @@ struct Stats {
    uint32_t queries_received;
    uint32_t queries_received;
    /// The number of accumulated QUIC connections accepted.
    /// The number of accumulated QUIC connections accepted.
    uint32_t connections_accepted;
    uint32_t connections_accepted;
    /// The number of QUIC connections alive.
    uint32_t alive_connections;
};
};


extern "C" {
extern "C" {
+8 −0
Original line number Original line Diff line number Diff line
@@ -222,6 +222,10 @@ impl Client {
    pub fn on_timeout(&mut self) {
    pub fn on_timeout(&mut self) {
        self.conn.on_timeout();
        self.conn.on_timeout();
    }
    }

    pub fn is_alive(&self) -> bool {
        self.conn.is_established() && !self.conn.is_closed()
    }
}
}


impl std::fmt::Debug for Client {
impl std::fmt::Debug for Client {
@@ -286,6 +290,10 @@ impl ClientMap {
        self.clients.iter_mut()
        self.clients.iter_mut()
    }
    }


    pub fn iter(&mut self) -> hash_map::Iter<ConnectionID, Client> {
        self.clients.iter()
    }

    pub fn len(&mut self) -> usize {
    pub fn len(&mut self) -> usize {
        self.clients.len()
        self.clients.len()
    }
    }
+5 −1
Original line number Original line Diff line number Diff line
@@ -368,7 +368,11 @@ async fn worker_thread(params: WorkerParams) -> Result<()> {
            Some(command) = command_rx.recv() => {
            Some(command) = command_rx.recv() => {
                match command {
                match command {
                    ControlCommand::Stats {resp} => {
                    ControlCommand::Stats {resp} => {
                        let stats = Stats {queries_received, connections_accepted: clients.len() as u32};
                        let stats = Stats {
                            queries_received,
                            connections_accepted: clients.len() as u32,
                            alive_connections: clients.iter().filter(|(_, client)| client.is_alive()).count() as u32,
                        };
                        if let Err(e) = resp.send(stats) {
                        if let Err(e) = resp.send(stats) {
                            error!("Failed to send ControlCommand::Stats response: {:?}", e);
                            error!("Failed to send ControlCommand::Stats response: {:?}", e);
                        }
                        }
+1 −0
Original line number Original line Diff line number Diff line
@@ -160,6 +160,7 @@ pub extern "C" fn frontend_stats(doh: &mut DohFrontend, out: &mut Stats) -> bool
        .map(|stats| {
        .map(|stats| {
            out.queries_received = stats.queries_received;
            out.queries_received = stats.queries_received;
            out.connections_accepted = stats.connections_accepted;
            out.connections_accepted = stats.connections_accepted;
            out.alive_connections = stats.alive_connections;
        })
        })
        .or_else(logging_and_return_err)
        .or_else(logging_and_return_err)
        .is_ok()
        .is_ok()
Loading