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

Commit 018c3dbf authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

DoH: Increase the size of Network mpsc channel am: 153b3fe1 am: 1f651757 am: 87e2eeda

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

Change-Id: I67587898726d55abe7ce1b3f13bdaa56a66cd7cd
parents eedf3efa 87e2eeda
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -283,6 +283,7 @@ impl H3Driver {
        // If the request has already timed out, don't issue it to the server.
        if let Some(expiry) = request.expiry {
            if BootTime::now() > expiry {
                warn!("Abandoning expired DNS request");
                return Ok(());
            }
        }
+9 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ use crate::config::Config;
use crate::connection::Connection;
use crate::dispatcher::{QueryError, Response};
use crate::encoding;
use anyhow::{anyhow, Result};
use anyhow::{anyhow, bail, Result};
use std::sync::Arc;
use tokio::sync::{mpsc, watch};
use tokio::task;
@@ -90,7 +90,7 @@ async fn build_connection(
}

impl Driver {
    const MAX_BUFFERED_COMMANDS: usize = 10;
    const MAX_BUFFERED_COMMANDS: usize = 50;

    pub async fn new(
        info: ServerInfo,
@@ -175,6 +175,13 @@ impl Driver {
    }

    async fn send_query(&mut self, query: Query) -> Result<()> {
        // If the associated receiver has been closed, meaning that the request has already
        // timed out, just drop it. This check helps drain the channel quickly in the case
        // where the network is stalled.
        if query.response.is_closed() {
            bail!("Abandoning expired DNS request")
        }

        if !self.connection.wait_for_live().await {
            // Try reconnecting
            self.connection =
+2 −2
Original line number Diff line number Diff line
@@ -703,11 +703,11 @@ TEST_F(PrivateDnsDohTest, TemporaryConnectionStalled) {
// Note: This test is subject to MAX_BUFFERED_COMMANDS. If the value is changed, this test might
// need to be modified as well.
TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
    const int total_queries = 20;
    const int total_queries = 70;

    // The number is from MAX_BUFFERED_COMMANDS + 2 (one that will be queued in
    // connection mpsc channel; the other one that will get blocked at dispatcher sending channel).
    const int timeout_queries = 12;
    const int timeout_queries = 52;

    const int initial_max_idle_timeout_ms = 2000;
    ASSERT_TRUE(doh.stopServer());